コード例 #1
0
ファイル: configuration.php プロジェクト: nemein/openpsa
 /**
  * Generic handler for all the DM2 based configuration requests
  *
  * @param string $handler_id    Name of the handler
  * @param array  $args          Variable arguments
  * @param array  &$data          Miscellaneous output data
  */
 public function _handler_config($handler_id, array $args, array &$data)
 {
     // Require corresponding ACL's
     $this->_topic->require_do('midgard:update');
     $this->_topic->require_do('midcom:component_config');
     // Add DM2 link head
     $this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/legacy.css');
     if (method_exists($this, '_load_datamanagers') && method_exists($this, '_load_objects')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'config/recreate/', MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('recreate images', 'midcom'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/recurring.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('midcom_baseclasses_components_handler_configuration_recreateok' => true)));
     }
     // Load the midcom_helper_datamanager2_controller for form processing
     $this->_controller = $this->get_controller('simple', $this->_topic);
     // Process the form
     switch ($this->_controller->process_form()) {
         case 'save':
             midcom::get('uimessages')->add($this->_l10n_midcom->get('component configuration'), $this->_l10n_midcom->get('configuration saved'));
             return new midcom_response_relocate('');
         case 'cancel':
             midcom::get('uimessages')->add($this->_l10n_midcom->get('component configuration'), $this->_l10n_midcom->get('cancelled'));
             return new midcom_response_relocate('');
     }
     // Update the breadcrumb and page title
     $this->add_breadcrumb('config/', $this->_l10n_midcom->get('component configuration'));
     $data['component'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT);
     $data['title'] = sprintf(midcom::get('i18n')->get_string('component %s configuration for folder %s', 'midcom'), midcom::get('i18n')->get_string($data['component'], $data['component']), $data['topic']->extra);
     midcom::get('head')->set_pagetitle($data['title']);
 }
コード例 #2
0
ファイル: metadata.php プロジェクト: nemein/openpsa
 /**
  * Handler for folder metadata. Checks for updating permissions, initializes
  * the metadata and the content topic itself. Handles also the sent form.
  *
  * @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_edit($handler_id, array $args, array &$data)
 {
     $this->_object = midcom::get('dbfactory')->get_object_by_guid($args[0]);
     // FIXME: We should modify the schema according to whether or not scheduling is used
     $this->_object->require_do('midgard:update');
     midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin');
     if (is_a($this->_object, 'midcom_db_topic')) {
         // This is a topic
         $this->_topic->require_do('midgard.admin.asgard:topic_management');
     }
     $this->_metadata = midcom_helper_metadata::retrieve($this->_object);
     if (!$this->_metadata) {
         throw new midcom_error("Failed to retrieve Metadata for " . get_class($this->_object) . " {$this->_object->guid}.");
     }
     // Load the DM2 controller instance
     $this->_controller = $this->get_controller('simple', $this->_object);
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the object
             //$indexer = midcom::get('indexer');
             //net_nemein_wiki_viewer::index($this->_request_data['controller']->datamanager, $indexer, $this->_topic);
             // *** FALL-THROUGH ***
             midcom::get('cache')->invalidate($this->_object->guid);
             return new midcom_response_relocate("__mfa/asgard/object/metadata/{$this->_object->guid}");
         case 'cancel':
             return new midcom_response_relocate("__mfa/asgard/object/view/{$this->_object->guid}");
     }
     $this->_prepare_request_data();
     midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data);
 }
コード例 #3
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;
     }
 }
コード例 #4
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);
 }
コード例 #5
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);
 }
コード例 #6
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}.");
     }
 }
コード例 #7
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}.");
     }
 }
コード例 #8
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}.");
     }
 }
コード例 #9
0
ファイル: lostpassword.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_lostpassword($handler_id, array $args, array &$data)
 {
     $this->_mode = $this->_config->get('lostpassword_mode');
     if ($this->_mode == 'none') {
         throw new midcom_error_notfound('This feature is disabled');
     }
     $this->_controller = $this->get_controller('nullstorage');
     switch ($this->_controller->process_form()) {
         case 'save':
             $this->_reset_password();
             $this->_processing_msg = $this->_l10n->get('password reset, mail sent.');
             $this->_processing_msg_raw = 'password reset, mail sent.';
             $this->_success = true;
             break;
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_prepare_request_data();
     midcom::get('head')->set_pagetitle($this->_l10n->get('lost password'));
 }
コード例 #10
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.");
     }
 }
コード例 #11
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.");
     }
 }
コード例 #12
0
ファイル: add.php プロジェクト: nemein/openpsa
 /**
  * loads the controller instance
  */
 private function _prepare_datamanager()
 {
     $this->_controller = $this->get_controller('create');
     // adjust cost per unit label
     // we have a percentage here?
     if ($this->_product->costType != "m") {
         $cost_per_unit_title = "cost per unit (percentage)";
         $this->_controller->schemadb["default"]->fields['costPerUnit']['title'] = $this->_l10n->get($cost_per_unit_title);
     }
     $this->_controller->initialize();
 }
コード例 #13
0
ファイル: simple.php プロジェクト: nemein/openpsa
 /**
  * Check if a schema has been set
  *
  * @param string $identifier The form identifier
  * @return boolean Indicating success.
  */
 function initialize($identifier = null)
 {
     parent::initialize($identifier);
     if (count($this->schemadb) == 0) {
         throw new midcom_error('You must set a schema database before initializing midcom_helper_datamanager2_controller_simple.');
     }
     if ($this->datamanager === null) {
         throw new midcom_error('You must set the datamanager member before initializing midcom_helper_datamanager2_controller_simple.');
     }
     $this->formmanager = new midcom_helper_datamanager2_formmanager($this->datamanager->schema, $this->datamanager->types);
     return $this->formmanager->initialize($identifier);
 }
コード例 #14
0
ファイル: view.php プロジェクト: nemein/openpsa
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_whatlinks($handler_id, array &$data)
 {
     if ($this->_controller) {
         $data['wikipage_view'] = $this->_controller->get_content_html();
     } else {
         $data['wikipage_view'] = $this->_datamanager->get_content_html();
     }
     // Replace wikiwords
     $parser = new net_nemein_wiki_parser($this->_page);
     $data['wikipage_view']['content'] = $parser->get_markdown($data['wikipage_view']['content']);
     midcom_show_style('view-wikipage-whatlinks');
 }
コード例 #15
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'];
 }
コード例 #16
0
ファイル: edit.php プロジェクト: nemein/openpsa
 /**
  * Handler for folder editing. Checks for the permissions and folder integrity.
  *
  * @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_edit($handler_id, array $args, array &$data)
 {
     $this->_topic->require_do('midcom.admin.folder:topic_management');
     $this->_handler_id = str_replace('____ais-folder-', '', $handler_id);
     if ($this->_handler_id == 'create' || $this->_handler_id == 'createlink') {
         $this->_topic->require_do('midgard:create');
         if ($this->_handler_id == 'createlink') {
             $this->_topic->require_do('midcom.admin.folder:symlinks');
         }
     } else {
         $this->_topic->require_do('midgard:update');
     }
     // Load the DM2 controller
     $this->_load_controller();
     // Get the content topic prefix
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     // Store the old name before editing
     $old_name = $this->_topic->name;
     // Symlink support requires that we use actual URL topic object here
     $urltopics = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_URLTOPICS);
     if ($urltopic = end($urltopics)) {
         $old_name = $urltopic->name;
     }
     switch ($this->_controller->process_form()) {
         case 'cancel':
             midcom::get('uimessages')->add($this->_l10n->get('midcom.admin.folder'), $this->_l10n->get('cancelled'));
             return new midcom_response_relocate($prefix);
         case 'save':
             if ($this->_handler_id === 'edit') {
                 $url = $this->_update_topic($prefix, $old_name);
             } else {
                 $url = $this->_create_topic($prefix);
             }
             return new midcom_response_relocate($url);
     }
     $this->_prepare_request_data();
     // Hide the button in toolbar
     $this->_node_toolbar->hide_item('__ais/folder/' . $this->_handler_id . '/');
     // Add the view to breadcrumb trail
     $this->add_breadcrumb('__ais/folder/edit/', $data['title']);
     // Set page title
     midcom::get('head')->set_pagetitle($data['title']);
     // Set the help object in the toolbar
     $help_toolbar = midcom::get('toolbars')->get_help_toolbar();
     $help_toolbar->add_help_item('edit_folder', 'midcom.admin.folder', null, null, 1);
     // Ensure we get the correct styles
     midcom::get('style')->prepend_component_styledir('midcom.admin.folder');
     $this->add_stylesheet(MIDCOM_STATIC_URL . '/midcom.admin.folder/folder.css');
 }
コード例 #17
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}");
 }
コード例 #18
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();
     }
 }
コード例 #19
0
ファイル: metadata.php プロジェクト: nemein/openpsa
 /**
  * Handler for folder metadata. Checks for updating permissions, initializes
  * the metadata and the content topic itself. Handles also the sent form.
  *
  * @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_metadata($handler_id, array $args, array &$data)
 {
     $this->_object = midcom::get('dbfactory')->get_object_by_guid($args[0]);
     // FIXME: We should modify the schema according to whether or not scheduling is used
     $this->_object->require_do('midgard:update');
     if (is_a($this->_object, 'midcom_db_topic')) {
         // This is a topic
         $this->_object->require_do('midcom.admin.folder:topic_management');
     } else {
         // This is a regular object, bind to view
         $this->bind_view_to_object($this->_object);
     }
     $this->_metadata = midcom_helper_metadata::retrieve($this->_object);
     if (!$this->_metadata) {
         throw new midcom_error("Failed to retrieve Metadata for " . get_class($this->_object) . " {$this->_object->guid}.");
     }
     // Load the DM2 controller instance
     $this->_load_datamanager();
     switch ($this->_controller->process_form()) {
         case 'save':
             midcom::get('cache')->invalidate($this->_object->guid);
         case 'cancel':
             return new midcom_response_relocate(midcom::get('permalinks')->create_permalink($this->_object->guid));
     }
     $object_label = midcom_helper_reflector::get($this->_object)->get_object_label($this->_object);
     if (is_a($this->_object, 'midcom_db_topic')) {
         $this->_node_toolbar->hide_item("__ais/folder/metadata/{$this->_object->guid}/");
     } else {
         $this->add_breadcrumb(midcom::get('permalinks')->create_permalink($this->_object->guid), $object_label);
         $this->_view_toolbar->hide_item("__ais/folder/metadata/{$this->_object->guid}/");
     }
     $this->add_breadcrumb("__ais/folder/metadata/{$this->_object->guid}/", $this->_l10n->get('edit metadata'));
     $data['title'] = sprintf(midcom::get('i18n')->get_string('edit metadata of %s', 'midcom.admin.folder'), $object_label);
     midcom::get('head')->set_pagetitle($data['title']);
     // Set the help object in the toolbar
     $help_toolbar = midcom::get('toolbars')->get_help_toolbar();
     $help_toolbar->add_help_item('edit_metadata', 'midcom.admin.folder', null, null, 1);
     // Ensure we get the correct styles
     midcom::get('style')->prepend_component_styledir('midcom.admin.folder');
 }
コード例 #20
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}.");
     }
 }
コード例 #21
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.");
             }
         }
     }
 }
コード例 #22
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;
 }
コード例 #23
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.');
     }
 }
コード例 #24
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);
 }
コード例 #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
ファイル: 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;
     }
 }
コード例 #27
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']);
 }
コード例 #28
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;
 }
コード例 #29
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);
 }
コード例 #30
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;
 }