コード例 #1
0
ファイル: edit.php プロジェクト: nemein/openpsa
 /**
  * Load either a create controller or an edit (simple) controller or trigger an error message
  */
 private function _load_controller()
 {
     // Get the configured schemas
     $schemadbs = $this->_config->get('schemadbs_folder');
     // Check if a custom schema exists
     if (array_key_exists($this->_topic->component, $schemadbs)) {
         $schemadb = $schemadbs[$this->_topic->component];
     } else {
         if (!array_key_exists('default', $schemadbs)) {
             throw new midcom_error('Configuration error. No default schema for topic has been defined!');
         }
         $schemadb = $schemadbs['default'];
     }
     $GLOBALS['midcom_admin_folder_mode'] = $this->_handler_id;
     // Create the schema instance
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb);
     switch ($this->_handler_id) {
         case 'edit':
             $this->_controller = midcom_helper_datamanager2_controller::create('simple');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->set_storage($this->_topic);
             break;
         case 'create':
             foreach ($this->_schemadb as $schema) {
                 if (isset($schema->fields['name'])) {
                     $schema->fields['name']['required'] = 0;
                 }
             }
             $this->_controller = midcom_helper_datamanager2_controller::create('create');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->schemaname = 'default';
             $this->_controller->callback_object =& $this;
             // Suggest to create the same type of a folder as the parent is
             $component_suggestion = $this->_topic->component;
             //Unless config told us otherwise
             if ($this->_config->get('default_component')) {
                 $component_suggestion = $this->_config->get('default_component');
             }
             $this->_controller->defaults = array('component' => $component_suggestion);
             break;
         case 'createlink':
             if (!array_key_exists('link', $schemadbs)) {
                 throw new midcom_error('Configuration error. No link schema for topic has been defined!');
             }
             $schemadb = $schemadbs['link'];
             // Create the schema instance
             $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb);
             $this->_schemadb->default->fields['name']['required'] = 0;
             $this->_controller = midcom_helper_datamanager2_controller::create('create');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->schemaname = 'link';
             $this->_controller->callback_object =& $this;
             break;
         default:
             throw new midcom_error('Unable to process the request, unknown handler id');
     }
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_event->id}.");
     }
 }
コード例 #2
0
ファイル: dm2.php プロジェクト: nemein/openpsa
 public function __construct($object = null)
 {
     $this->_object = $object;
     $schemadb_raw = array('default' => array('description' => __CLASS__ . ' testcase schema', 'fields' => array()));
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb_raw);
     if ($this->_object) {
         if (!empty($this->_object->id)) {
             $controller_type = 'simple';
         } else {
             $controller_type = 'create';
         }
     } else {
         $controller_type = 'nullstorage';
     }
     $this->_controller = midcom_helper_datamanager2_controller::create($controller_type);
     $this->_controller->schemaname = 'default';
     $this->_controller->schemadb =& $this->_schemadb;
     switch ($controller_type) {
         case 'create':
             $this->_controller->callback_object =& $this;
         case 'nullstorage':
             $this->_controller->defaults =& $this->defaults;
             break;
     }
 }
コード例 #3
0
ファイル: admin.php プロジェクト: nemein/openpsa
 /**
  * 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);
 }
コード例 #4
0
ファイル: edit.php プロジェクト: nemein/openpsa
 /**
  * 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);
 }
コード例 #5
0
ファイル: admin.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, loads the controller for the current document. Any error triggers a 500.
  */
 private function _load_edit_controller()
 {
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->set_storage($this->_document, $this->_schema);
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for document {$this->_document->id}.");
     }
 }
コード例 #6
0
ファイル: edit.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, loads the controller for the current directoy. Any error triggers a 500.
  */
 private function _load_edit_controller()
 {
     $this->_load_schemadb();
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->set_storage($this->_request_data['directory'], $this->_schema);
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for task {$this->_directory->id}.");
     }
 }
コード例 #7
0
ファイル: edit.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, loads the controller for the current article. Any error triggers a 500.
  */
 private function _load_controller()
 {
     $this->_load_schemadb();
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->set_storage($this->_page);
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_article->id}.");
     }
 }
コード例 #8
0
ファイル: create.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, fires up the creation mode controller. Any error triggers a 500.
  */
 private function _load_create_controller()
 {
     $this->_controller = midcom_helper_datamanager2_controller::create('create');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->schemaname = $this->_schema;
     $this->_controller->callback_object =& $this;
     $this->_controller->defaults =& $this->_defaults;
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 create controller.");
     }
 }
コード例 #9
0
ファイル: create.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, fires up the creation mode controller. Any error triggers a 500.
  */
 private function _load_create_controller()
 {
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_directory'));
     $this->_controller = midcom_helper_datamanager2_controller::create('create');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->schemaname = $this->_schema;
     $this->_controller->callback_object =& $this;
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 create controller.");
     }
 }
コード例 #10
0
ファイル: suggestion.php プロジェクト: nemein/opengov
 /**
  * Internal helper, loads the controller. Any error triggers a 500.
  * @param type of the controller (e.g. simple, create)
  * @access private
  */
 function _load_controller($type)
 {
     $this->_request_data['controller'] =& midcom_helper_datamanager2_controller::create($type);
     $this->_request_data['controller']->schemadb =& $this->_schemadb;
     $this->_request_data['controller']->schema = 'default';
     $this->_request_data['controller']->callback_object =& $this;
     if ($type == 'simple') {
         $this->_request_data['controller']->set_storage($this->_object, 'default');
     }
     if (!$this->_request_data['controller']->initialize()) {
         $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 create controller.");
     }
     $this->_controller = $this->_request_data['controller'];
 }
コード例 #11
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, loads the datamanager for the current wikipage. Any error triggers a 500.
  */
 private function _load_datamanager()
 {
     if ($GLOBALS['midcom_config']['enable_ajax_editing']) {
         $this->_controller = midcom_helper_datamanager2_controller::create('ajax');
         $this->_controller->schemadb =& $this->_request_data['schemadb'];
         $this->_controller->set_storage($this->_page);
         $this->_controller->process_ajax();
         $this->_datamanager =& $this->_controller->datamanager;
     } else {
         $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_request_data['schemadb']);
         if (!$this->_datamanager->autoset_storage($this->_page)) {
             throw new midcom_error("Failed to create a DM2 instance for wiki page {$this->_page->guid}.");
         }
     }
 }
コード例 #12
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Looks up a deliverable 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_view($handler_id, array $args, array &$data)
 {
     $this->_deliverable = new org_openpsa_sales_salesproject_deliverable_dba($args[0]);
     $this->_salesproject = new org_openpsa_sales_salesproject_dba($this->_deliverable->salesproject);
     $this->_load_schema();
     $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
     $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb_salesproject_deliverable'];
     $this->_request_data['controller']->set_storage($this->_deliverable);
     $this->_request_data['controller']->process_ajax();
     org_openpsa_sales_viewer::add_breadcrumb_path($this->_deliverable, $this);
     $this->_prepare_request_data();
     $this->bind_view_to_object($this->_deliverable);
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.core/list.css");
     org_openpsa_widgets_ui::enable_ui_tab();
     midcom::get('metadata')->set_request_metadata($this->_deliverable->metadata->revised, $this->_deliverable->guid);
     midcom::get('head')->set_pagetitle("{$this->_salesproject->title}: {$this->_deliverable->title}");
 }
コード例 #13
0
ファイル: formmailer.php プロジェクト: nemein/openpsa
 public function process()
 {
     $controller = midcom_helper_datamanager2_controller::create('nullstorage');
     $controller->schemadb = $this->_schemadb;
     $controller->schemaname = 'default';
     if (!$controller->initialize()) {
         throw new midcom_error('Failed to initialize a DM2 nullstorage controller.');
     }
     switch ($controller->process_form()) {
         case 'save':
             $this->_send_form($controller->datamanager->get_content_email());
             break;
         case 'cancel':
             //Clear form
             midcom::get()->relocate($_SERVER['REQUEST_URI']);
         default:
             $controller->display_form();
     }
 }
コード例 #14
0
ファイル: metadata.php プロジェクト: nemein/openpsa
 /**
  * Load the DM2 edit controller instance
  *
  * @return boolean Indicating success of DM2 edit controller instance
  */
 private function _load_datamanager()
 {
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($GLOBALS['midcom_config']['metadata_schema']);
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb =& $this->_schemadb;
     // Check if we have metadata schema defined in the schemadb specific for the object's schema or component
     $object_schema = $this->_object->get_parameter('midcom.helper.datamanager2', 'schema_name');
     $component_schema = str_replace('.', '_', midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT));
     if ($object_schema == '' || !isset($this->_schemadb[$object_schema])) {
         if (isset($this->_schemadb[$component_schema])) {
             // No specific metadata schema for object, fall back to component-specific metadata schema
             $object_schema = $component_schema;
         } else {
             // No metadata schema for component, fall back to default
             $object_schema = 'metadata';
         }
     }
     $this->_controller->set_storage($this->_object, $object_schema);
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_article->id}.");
     }
 }
コード例 #15
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Initializes a DM2 for posting.
  */
 function _init_post_controller()
 {
     $this->_load_schemadb();
     $defaults = array();
     if (midcom::get('auth')->user) {
         $defaults['author'] = midcom::get('auth')->user->name;
     }
     $this->_post_controller = midcom_helper_datamanager2_controller::create('create');
     $this->_post_controller->schemadb =& $this->_schemadb;
     $this->_post_controller->schema = 'comment';
     $this->_post_controller->defaults = $defaults;
     $this->_post_controller->callback_object =& $this;
     if (!$this->_post_controller->initialize()) {
         throw new midcom_error('Failed to initialize a DM2 create controller.');
     }
 }
コード例 #16
0
ファイル: list.php プロジェクト: nemein/openpsa
 private function _create_controller(&$data)
 {
     // Run datamanager for handling the images
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb = $this->_load_schema($data['schema_name']);
     $this->_controller->schemaname = $data['schema_name'];
     if ($data['list_type'] == 'page') {
         $this->_controller->set_storage($data['object']);
     } else {
         $this->_controller->set_storage($data['folder']);
     }
     $this->_controller->initialize();
     $this->_request_data['form'] =& $this->_controller;
     switch ($this->_controller->process_form()) {
         case 'cancel':
             midcom::get('head')->add_jsonload("window.close();");
             break;
     }
     midcom::get('head')->add_jsonload("jQuery('.midcom_helper_datamanager2_widget_images_image').dm2ImagePopupConvert()");
     midcom::get('head')->add_jsonload("jQuery('.midcom_helper_datamanager2_widget_downloads_download').dm2ImagePopupConvert();");
 }
コード例 #17
0
ファイル: list.php プロジェクト: nemein/openpsa
 /**
  * The handler for the group_list article.
  *
  * @param mixed $handler_id the array key from the request array
  * @param array $args the arguments given to the handler
  * @param Array &$data The local request data.
  */
 public function _handler_list($handler_id, array $args, array &$data)
 {
     // Query for sub-objects
     if ($handler_id == 'list_intree') {
         $this->_handle_list_intree($args);
     } else {
         if ($handler_id == 'listall') {
             $this->_handle_listall($args);
         } else {
             if ($handler_id == 'list') {
                 $this->_handle_list($args);
             }
         }
     }
     $group_qb = org_openpsa_products_product_group_dba::new_query_builder();
     $group_qb->add_constraint('up', '=', $data['parent_group']);
     foreach ($this->_config->get('groups_listing_order') as $ordering) {
         $this->_add_ordering($group_qb, $ordering);
     }
     $this->_request_data['linked_products'] = array();
     if ($this->_config->get('enable_productlinks')) {
         $mc_productlinks = org_openpsa_products_product_link_dba::new_collector('productGroup', $data['parent_group']);
         $this->_request_data['linked_products'] = $mc_productlinks->get_values('product');
     }
     $data['groups'] = $group_qb->execute();
     $data['products'] = array();
     if ($this->_config->get('group_list_products')) {
         $this->_list_group_products();
     }
     // Prepare datamanager
     $data['datamanager_group'] = new midcom_helper_datamanager2_datamanager($data['schemadb_group']);
     $data['datamanager_product'] = new midcom_helper_datamanager2_datamanager($data['schemadb_product']);
     $this->_populate_toolbar();
     if ($data['group']) {
         if ($GLOBALS['midcom_config']['enable_ajax_editing']) {
             $data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
             $data['controller']->schemadb =& $data['schemadb_group'];
             $data['controller']->set_storage($data['group']);
             $data['controller']->process_ajax();
             $data['datamanager_group'] =& $data['controller']->datamanager;
         } else {
             $data['controller'] = null;
             if (!$data['datamanager_group']->autoset_storage($data['group'])) {
                 throw new midcom_error("Failed to create a DM2 instance for product group {$data['group']->guid}.");
             }
         }
         $this->bind_view_to_object($data['group'], $data['datamanager_group']->schema->name);
     }
     $this->_update_breadcrumb_line();
     // Set the active leaf
     if ($this->_config->get('display_navigation') && $this->_request_data['group']) {
         $group = $this->_request_data['group'];
         // Loop as long as it is possible to get the parent group
         while ($group->guid) {
             // Break to the requested level (probably the root group of the products content topic)
             if ($group->id === $this->_config->get('root_group') || $group->guid === $this->_config->get('root_group')) {
                 break;
             }
             $temp = $group->id;
             if ($group->up == 0) {
                 break;
             }
             $group = new org_openpsa_products_product_group_dba($group->up);
         }
         if (isset($temp)) {
             // Active leaf of the topic
             $this->set_active_leaf($temp);
         }
     }
     midcom::get('head')->set_pagetitle($this->_request_data['view_title']);
 }
コード例 #18
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Handle actual article 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_view($handler_id, array $args, array &$data)
 {
     if ($handler_id == 'view-raw') {
         midcom::get()->skip_page_style = true;
     }
     $this->_load_datamanager();
     if ($this->_config->get('enable_ajax_editing')) {
         $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
         $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb'];
         $this->_request_data['controller']->set_storage($this->_article);
         $this->_request_data['controller']->process_ajax();
     }
     if ($this->_config->get('comments_enable')) {
         $comments_node = $this->_seek_comments();
         if ($comments_node) {
             $this->_request_data['comments_url'] = $comments_node[MIDCOM_NAV_RELATIVEURL] . "comment/{$this->_article->guid}";
             if ($this->_topic->can_do('midgard:update') && $this->_topic->can_do('net.nehmer.comments:moderation')) {
                 net_nehmer_comments_viewer::add_head_elements();
             }
         }
         // TODO: Should we tell admin to create a net.nehmer.comments folder?
     }
     $tmp = array();
     $arg = $this->_article->name ? $this->_article->name : $this->_article->guid;
     if ($this->_config->get('view_in_url')) {
         $view_url = "view/{$arg}/";
     } else {
         $view_url = "{$arg}/";
     }
     $this->add_breadcrumb($view_url, $this->_article->title);
     $this->_prepare_request_data();
     if ($this->_config->get('enable_article_links') && $this->_content_topic->can_do('midgard:create')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('article link')), MIDCOM_TOOLBAR_URL => "create/link/?article={$this->_article->id}", MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/attach.png'));
     }
     $this->bind_view_to_object($this->_article, $this->_datamanager->schema->name);
     midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid);
     midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}");
 }
コード例 #19
0
ファイル: manage.php プロジェクト: nemein/openpsa
 private function _load_controller(&$data)
 {
     $data['schemadb'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_feed'));
     $data['controller'] = midcom_helper_datamanager2_controller::create('simple');
     $data['controller']->schemadb =& $data['schemadb'];
     $data['controller']->set_storage($data['feed']);
     if (!$data['controller']->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for feed {$data['feed']->id}.");
     }
 }
コード例 #20
0
ファイル: composite.php プロジェクト: nemein/openpsa
 function _load_creation_controllers()
 {
     if (!$this->enable_creation) {
         return false;
     }
     if (!is_null($this->maximum_items) && count($this->objects) >= $this->maximum_items) {
         return false;
     }
     if ($this->storage->object->can_do('midgard:create')) {
         foreach (array_keys($this->_schemadb) as $name) {
             $this->_creation_controllers[$name] = midcom_helper_datamanager2_controller::create('create');
             $this->_creation_controllers[$name]->form_identifier = "create_{$this->name}_{$name}";
             $this->_creation_controllers[$name]->ajax_mode = true;
             $this->_creation_controllers[$name]->ajax_options = array();
             if ($this->window_mode) {
                 $this->_creation_controllers[$name]->window_mode = $this->window_mode;
                 $this->_creation_controllers[$name]->ajax_options['window_mode'] = $this->window_mode;
             }
             if ($this->wide_mode) {
                 $this->_creation_controllers[$name]->wide_mode = $this->wide_mode;
                 $this->_creation_controllers[$name]->ajax_options['wide_mode'] = $this->wide_mode;
             }
             $this->_creation_controllers[$name]->schemadb = $this->_schemadb;
             $this->_creation_controllers[$name]->schemaname = $name;
             $this->_creation_controllers[$name]->callback_object = $this;
             $this->_creation_controllers[$name]->callback_method = 'create_object';
             $this->_creation_controllers[$name]->defaults = $this->defaults;
             if (!$this->_creation_controllers[$name]->initialize()) {
                 throw new midcom_error("Failed to initialize a DM2 create controller.");
             }
         }
     }
 }
コード例 #21
0
ファイル: viewer.php プロジェクト: nemein/openpsa
 /**
  * @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_settings($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     $this->_check_imp_settings();
     // Load the schema definition file
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_horde_account'));
     //Choose schema
     if ($this->_global_server) {
         $schema = 'globalserver';
     } else {
         $schema = 'default';
     }
     debug_add('Chose schema: "' . $schema . '"');
     // Instantiate datamanager
     $controller = midcom_helper_datamanager2_controller::create('simple');
     $controller->schemadb =& $schemadb;
     // Load the person record into DM
     $person_record = midcom::get('auth')->user->get_storage();
     $controller->set_storage($person_record, $schema);
     if (!$controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for person {$person_record->id}.");
     }
     // Process the form
     switch ($controller->process_form()) {
         case 'save':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX));
         case 'cancel':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX));
     }
     $data['controller'] = $controller;
 }
コード例 #22
0
ファイル: admin.php プロジェクト: nemein/openpsa
 /**
  * Looks up an hour_report to edit.
  *
  * @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->_hour_report = new org_openpsa_projects_hour_report_dba($args[0]);
     $this->_load_schemadb();
     $this->_controller = midcom_helper_datamanager2_controller::create('simple');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->set_storage($this->_hour_report);
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for hour_report {$this->_hour_report->id}.");
     }
     switch ($this->_controller->process_form()) {
         case 'save':
             $this->_hour_report->modify_hours_by_time_slot();
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             $task = new org_openpsa_projects_task_dba($this->_hour_report->task);
             return new midcom_response_relocate("hours/task/" . $task->guid . "/");
     }
     $this->_prepare_request_data();
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "hours/delete/{$this->_hour_report->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd'));
     $parent = $this->_hour_report->get_parent();
     $this->_add_toolbar_items($parent);
     $this->_view_toolbar->bind_to($this->_hour_report);
     midcom::get('metadata')->set_request_metadata($this->_hour_report->metadata->revised, $this->_hour_report->guid);
     midcom::get('head')->set_pagetitle($this->_l10n->get($handler_id));
     $this->_update_breadcrumb_line($handler_id);
 }
コード例 #23
0
ファイル: admin.php プロジェクト: nemein/openpsa
 /**
  * Handle the message copying interface
  *
  * @return boolean Indicating success
  */
 public function _handler_copy($handler_id, array $args, array &$data)
 {
     $this->_topic->require_do('midgard:create');
     $this->_message = new org_openpsa_directmarketing_campaign_message_dba($args[0]);
     $guid = $args[0];
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_message_copy'));
     $this->_controller = midcom_helper_datamanager2_controller::create('nullstorage');
     $this->_controller->schemadb =& $this->_schemadb;
     $this->_controller->initialize();
     $data['targets'] = array();
     switch ($this->_controller->process_form()) {
         case 'save':
             $copy = new midcom_helper_reflector_copy();
             $campaigns = $this->_controller->datamanager->types['campaign']->convert_to_storage();
             $copy_objects = array();
             foreach ($campaigns as $campaign_id) {
                 try {
                     $campaign = new org_openpsa_directmarketing_campaign_dba($campaign_id);
                 } catch (midcom_error $e) {
                     continue;
                 }
                 $new_object = $copy->copy_object($this->_message->guid, $campaign);
                 $guid = $new_object->guid;
                 // Store for later use
                 $copy_objects[] = $new_object;
             }
             if (count($copy_objects) > 1) {
                 $data['targets'] =& $copy_objects;
                 break;
             }
             // Fall through
         // Fall through
         case 'cancel':
             return new midcom_response_relocate("message/{$guid}/");
     }
     midcom::get('head')->set_pagetitle($this->_message->title);
     $this->bind_view_to_object($this->_message);
     $this->_update_breadcrumb_line($handler_id);
 }
コード例 #24
0
ファイル: manage.php プロジェクト: nemein/openpsa
 /**
  * Copy handler
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 public function _handler_copy($handler_id, array $args, array &$data)
 {
     // Get the object that will be copied
     $this->_load_object($args[0]);
     midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin');
     static $targets = array();
     $mgdschema_class = midcom_helper_reflector::resolve_baseclass(get_class($this->_object));
     // Get the target details
     if (in_array($mgdschema_class, $targets)) {
         $target = $targets[$mgdschema_class];
     } else {
         $target = midcom_helper_reflector_copy::get_target_properties($this->_object);
     }
     // Load the schemadb for searching the parent object
     $this->_load_schemadb($target['class'], $target['parent'], true);
     // Change the name for the parent field
     $this->_schemadb['object']->fields[$target['parent']]['title'] = $this->_l10n->get('choose the target');
     // Load the nullstorage controller
     $this->_controller = midcom_helper_datamanager2_controller::create('nullstorage');
     $this->_controller->schemadb =& $this->_schemadb;
     if (!$this->_controller->initialize()) {
         throw new midcom_error('Failed to initialize the controller');
     }
     $this->_prepare_request_data();
     // Process the form
     switch ($this->_controller->process_form()) {
         case 'save':
             $new_object = $this->_process_copy($target);
             // Relocate to the newly created object
             return new midcom_response_relocate("__mfa/asgard/object/{$this->_request_data['default_mode']}/{$new_object->guid}/");
         case 'cancel':
             return new midcom_response_relocate("__mfa/asgard/object/{$this->_request_data['default_mode']}/{$args[0]}/");
     }
     // Add Thickbox
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/object_browser.js');
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/jQuery/thickbox/jquery-thickbox-3.1.pack.js');
     $this->add_stylesheet(MIDCOM_STATIC_URL . '/jQuery/thickbox/thickbox.css', 'screen');
     midcom::get('head')->add_jscript('var tb_pathToImage = "' . MIDCOM_STATIC_URL . '/jQuery/thickbox/loadingAnimation.gif"');
     // Add jQuery file for the checkbox operations
     midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/jquery-copytree.js');
     midcom::get('head')->add_jscript('jQuery(document).ready(function(){jQuery("#midgard_admin_asgard_copytree").tree_checker();})');
     // Common hooks for Asgard
     midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data);
     // Set the page title
     switch ($handler_id) {
         case '____mfa-asgard-object_copy_tree':
             $data['page_title'] = sprintf($this->_l10n->get('copy %s and its descendants'), $this->_object->{$target}['label']);
             break;
         default:
             $data['page_title'] = sprintf($this->_l10n->get('copy %s'), $this->_object->{$target}['label']);
     }
     $data['target'] = $target;
 }
コード例 #25
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * 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_view($handler_id, array $args, array &$data)
 {
     if (preg_match('/_raw$/', $handler_id)) {
         midcom::get()->skip_page_style = true;
     }
     $qb = org_openpsa_products_product_dba::new_query_builder();
     if (preg_match('/^view_product_intree/', $handler_id)) {
         $group_qb = org_openpsa_products_product_group_dba::new_query_builder();
         if (mgd_is_guid($args[0])) {
             $group_qb->add_constraint('guid', '=', $args[0]);
         } else {
             $group_qb->add_constraint('code', '=', $args[0]);
         }
         $groups = $group_qb->execute();
         if (empty($groups)) {
             throw new midcom_error_notfound("Product group {$args[0]} not found");
         }
         $categories_mc = org_openpsa_products_product_group_dba::new_collector('up', $groups[0]->id);
         $categories_in = $categories_mc->get_values('id');
         if (count($categories_in) == 0) {
             /* No matching categories belonging to this group
              * So we can search for the application using only
              * this group id
              */
             $qb->add_constraint('productGroup', 'INTREE', $groups[0]->id);
         } else {
             $categories_in[] = $groups[0]->id;
             $qb->add_constraint('productGroup', 'IN', $categories_in);
         }
         if (mgd_is_guid($args[1])) {
             $qb->add_constraint('guid', '=', $args[1]);
         } else {
             $qb->add_constraint('code', '=', $args[1]);
         }
     } else {
         if (mgd_is_guid($args[0])) {
             $qb->add_constraint('guid', '=', $args[0]);
         } else {
             $qb->add_constraint('code', '=', $args[0]);
         }
     }
     if ($this->_config->get('enable_scheduling')) {
         $qb->add_constraint('start', '<=', time());
         $qb->begin_group('OR');
         /*
          * List products that either have no defined end-of-market dates
          * or are still in market
          */
         $qb->add_constraint('end', '=', 0);
         $qb->add_constraint('end', '>=', time());
         $qb->end_group();
     }
     $results = $qb->execute();
     $this->_request_data['is_linked_from'] = '';
     if (!empty($results)) {
         $this->_product = $results[0];
         if ($this->_config->get('enable_productlinks') && $this->_product->productGroup != 0) {
             $root_group_guid = $this->_config->get('root_group');
             if ($root_group_guid != '') {
                 $root_group = org_openpsa_products_product_group_dba::get_cached($root_group_guid);
             }
             if ($root_group->id != $this->_product->productGroup) {
                 $product_group = new org_openpsa_products_product_group_dba($this->_product->productGroup);
                 $mc_intree = org_openpsa_products_product_group_dba::new_collector('id', $product_group->id);
                 $mc_intree->add_constraint('up', 'INTREE', $root_group->id);
                 $count = $mc_intree->count();
                 if ($count == 0) {
                     $mc_intree = org_openpsa_products_product_link_dba::new_collector('product', $this->_product->id);
                     $mc_intree->add_constraint('productGroup', 'INTREE', $root_group->id);
                     $mc_intree->execute();
                     $results = $mc_intree->list_keys();
                     if (count($results) > 0) {
                         foreach ($results as $guid => $array) {
                             $this->_request_data['is_linked_from'] = $guid;
                         }
                     }
                 }
             }
         }
     } else {
         if (preg_match('/^view_product_intree/', $handler_id)) {
             $this->_product = new org_openpsa_products_product_dba($args[1]);
         } else {
             $this->_product = new org_openpsa_products_product_dba($args[0]);
         }
     }
     if ($GLOBALS['midcom_config']['enable_ajax_editing']) {
         $data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
         $data['controller']->schemadb =& $data['schemadb_product'];
         $data['controller']->set_storage($this->_product);
         $data['controller']->process_ajax();
         $data['datamanager'] =& $data['controller']->datamanager;
     } else {
         $data['controller'] = null;
         $data['datamanager'] = new midcom_helper_datamanager2_datamanager($data['schemadb_product']);
         if (!$data['datamanager']->autoset_storage($this->_product)) {
             throw new midcom_error("Failed to create a DM2 instance for product {$this->_product->guid}.");
         }
     }
     $this->_prepare_request_data();
     $this->bind_view_to_object($this->_product, $data['datamanager']->schema->name);
     if (isset($product_group)) {
         unset($product_group);
     }
     $product_group = null;
     if ($this->_request_data['is_linked_from'] != '') {
         $linked_product = new org_openpsa_products_product_link_dba($data['is_linked_from']);
         if ($linked_product->productGroup != 0) {
             $product_group = new org_openpsa_products_product_group_dba($linked_product->productGroup);
         }
     }
     $breadcrumb = org_openpsa_products_viewer::update_breadcrumb_line($this->_product, $product_group);
     midcom_core_context::get()->set_custom_key('midcom.helper.nav.breadcrumb', $breadcrumb);
     midcom::get('metadata')->set_request_metadata($this->_product->metadata->revised, $this->_product->guid);
     $title = $this->_config->get('product_page_title');
     if (strstr($title, '<PRODUCTGROUP')) {
         try {
             $productgroup = new org_openpsa_products_product_group_dba($this->_product->productGroup);
             $title = str_replace('<PRODUCTGROUP_TITLE>', $productgroup->title, $title);
             $title = str_replace('<PRODUCTGROUP_CODE>', $productgroup->code, $title);
         } catch (midcom_error $e) {
             $title = str_replace('<PRODUCTGROUP_TITLE>', '', $title);
             $title = str_replace('<PRODUCTGROUP_CODE>', '', $title);
         }
     }
     $title = str_replace('<PRODUCT_CODE>', $this->_product->code, $title);
     $title = str_replace('<PRODUCT_TITLE>', $this->_product->title, $title);
     $title = str_replace('<TOPIC_TITLE>', $this->_topic->extra, $title);
     midcom::get('head')->set_pagetitle($title);
 }
コード例 #26
0
ファイル: handler.php プロジェクト: nemein/openpsa
 /**
  * Loads and prepares a delete controller. Any error triggers a 500.
  *
  * @return midcom_helper_datamanager2_controller_nullstorage The delete controller
  */
 public static function get_delete_controller()
 {
     $controller = midcom_helper_datamanager2_controller::create('nullstorage');
     $delete_schemadb = midcom_baseclasses_components_configuration::get('midcom.helper.datamanager2', 'config')->get('schemadb_delete');
     $controller->schemadb = midcom_helper_datamanager2_schema::load_database($delete_schemadb);
     if (!$controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for object {$object->guid}.");
     }
     return $controller;
 }
コード例 #27
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Looks up an article to display. If the handler_id is 'index', the index article is tried to be
  * looked up, otherwise the article name is taken from args[0]. Triggered error messages are
  * generated accordingly. A missing index will trigger a forbidden error, a missing regular
  * article a 404 (from can_handle).
  *
  * 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_view($handler_id, array $args, array &$data)
 {
     if ($handler_id == 'index') {
         $this->_load_index_article();
     }
     if ($handler_id == 'view_raw') {
         midcom::get()->skip_page_style = true;
     }
     $this->_load_datamanager();
     if ($this->_config->get('enable_ajax_editing')) {
         $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
         $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb'];
         $this->_request_data['controller']->set_storage($this->_article);
         $this->_request_data['controller']->process_ajax();
     }
     $arg = $this->_article->name ? $this->_article->name : $this->_article->guid;
     if ($arg != 'index' && $this->_config->get('hide_navigation')) {
         $this->add_breadcrumb("{$arg}/", $this->_article->title);
     }
     $this->_prepare_request_data();
     if ($this->_config->get('enable_article_links') && $this->_content_topic->can_do('midgard:create')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('article link')), MIDCOM_TOOLBAR_URL => "create/link/?article={$this->_article->id}", MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/attach.png'));
     }
     midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid);
     $this->bind_view_to_object($this->_article, $this->_datamanager->schema->name);
     if ($this->_config->get('indexinnav') || $this->_config->get('autoindex') || $this->_article->name != 'index') {
         $this->set_active_leaf($this->_article->id);
     }
     if ($this->_config->get('folder_in_title') && $this->_topic->extra != $this->_article->title) {
         midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}");
     } else {
         midcom::get('head')->set_pagetitle($this->_article->title);
     }
 }
コード例 #28
0
ファイル: crud.php プロジェクト: nemein/openpsa
 /**
  * Internal helper, loads the controller for the current object. Any error triggers a 500.
  *
  * @param string $type Controller to instantiate (typically 'simple' or 'ajax')
  */
 public function _load_controller($type = 'simple')
 {
     $this->_controller = midcom_helper_datamanager2_controller::create($type);
     $this->_controller->schemadb =& $this->_schemadb;
     if ($type == 'create') {
         // Creation controller, give additional parameters
         $this->_controller->schemaname = $this->_schema;
         $this->_controller->defaults = $this->_defaults;
         $this->_controller->callback_object =& $this;
     } else {
         if (!$this->_object) {
             throw new midcom_error_notfound("No object defined for DM2.");
         }
         $this->_controller->set_storage($this->_object);
     }
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for object {$this->_object->guid}.");
     }
 }
コード例 #29
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  * Helper that lists all deliverables belonging to the current project
  */
 private function _list_deliverables()
 {
     $qb = org_openpsa_sales_salesproject_deliverable_dba::new_query_builder();
     $qb->add_constraint('salesproject', '=', $this->_salesproject->id);
     $qb->add_constraint('up', '=', 0);
     if ($this->_salesproject->status != org_openpsa_sales_salesproject_dba::STATUS_LOST) {
         $qb->add_constraint('state', '<>', org_openpsa_sales_salesproject_deliverable_dba::STATUS_DECLINED);
     }
     $qb->add_order('state');
     $qb->add_order('metadata.created', 'DESC');
     $deliverables = $qb->execute();
     foreach ($deliverables as $deliverable) {
         $this->_controllers[$deliverable->id] = midcom_helper_datamanager2_controller::create('ajax');
         $this->_controllers[$deliverable->id]->schemadb =& $this->_request_data['schemadb_salesproject_deliverable'];
         $this->_controllers[$deliverable->id]->set_storage($deliverable);
         $this->_controllers[$deliverable->id]->process_ajax();
         $this->_request_data['deliverables_objects'][$deliverable->guid] = $deliverable;
     }
 }