Example #1
0
 /**
  * Displays an object delete confirmation view.
  *
  * Note, that the object for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation object
  *
  * @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_delete($handler_id, array $args, array &$data)
 {
     $this->_mode = 'delete';
     $this->_load_object($handler_id, $args, $data);
     $this->_object->require_do('midgard:delete');
     $this->_load_schemadb();
     $this->_load_datamanager();
     $this->_controller = midcom_helper_datamanager2_handler::get_delete_controller();
     switch ($this->_controller->process_form()) {
         case 'delete':
             // Deletion confirmed, try doing it.
             if (!$this->_object->delete()) {
                 throw new midcom_error("Failed to delete object {$this->_object->guid}, last Midgard error was: " . midcom_connection::get_error_string());
             }
             // Update the index
             $indexer = midcom::get('indexer');
             $indexer->delete($this->_object->guid);
             // Show user interface message
             // midcom::get('uimessages')->add($this->_l10n->get('net.nehmer.blog'), sprintf($this->_l10n->get('object %s deleted'), $title));
             // Delete ok, relocating to welcome.
             return new midcom_response_relocate('');
         case 'cancel':
             return new midcom_response_relocate($this->_get_object_url());
     }
     $this->_prepare_request_data();
     // Call the per-component metadata methods
     $this->_populate_toolbar($handler_id);
     $this->_update_title($handler_id);
     $this->_update_breadcrumb($handler_id);
     // Let MidCOM know about the object
     midcom::get('metadata')->set_request_metadata($this->_object->metadata->revised, $this->_object->guid);
     $this->bind_view_to_object($this->_object, $this->_datamanager->schema->name);
     $this->_handler_callback($handler_id, $args, $data);
 }
Example #2
0
 /**
  * Displays an article edit view.
  *
  * Note, that the article for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation article
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_article = new midcom_db_article($args[0]);
     // Relocate for the correct content topic, let the true content topic take care of the ACL
     if ($this->_article->topic !== $this->_content_topic->id) {
         $nap = new midcom_helper_nav();
         $node = $nap->get_node($this->_article->topic);
         if ($node && isset($node[MIDCOM_NAV_FULLURL])) {
             return new midcom_response_relocate($node[MIDCOM_NAV_FULLURL] . "edit/{$args[0]}/");
         }
         throw new midcom_error_notfound("The article with GUID {$args[0]} was not found.");
     }
     $this->_article->require_do('midgard:update');
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the article
             $indexer = midcom::get('indexer');
             net_nehmer_blog_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             if ($this->_config->get('view_in_url')) {
                 return new midcom_response_relocate("view/{$this->_article->name}/");
             } else {
                 return new midcom_response_relocate("{$this->_article->name}/");
             }
     }
     $this->_prepare_request_data();
     $this->_view_toolbar->bind_to($this->_article);
     midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid);
     midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}");
     $this->_update_breadcrumb_line($handler_id);
 }
Example #3
0
 /**
  * @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)
 {
     midcom::get('auth')->require_valid_user();
     $this->_document = $this->_load_document($args[0]);
     $this->_document->require_do('midgard:update');
     $this->_load_edit_controller();
     if ($data['enable_versioning'] && !empty($_POST)) {
         $this->_backup_attachment();
     }
     switch ($this->_controller->process_form()) {
         case 'save':
             // TODO: Update the URL name?
             // Update the Index
             $indexer = new org_openpsa_documents_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             if ($this->_document->topic != $this->_topic->id) {
                 $nap = new midcom_helper_nav();
                 $node = $nap->get_node($this->_document->topic);
                 $prefix = $node[MIDCOM_NAV_ABSOLUTEURL];
             }
             return new midcom_response_relocate($prefix . "document/" . $this->_document->guid . "/");
         case 'cancel':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "document/" . $this->_document->guid . "/");
     }
     $this->_request_data['controller'] =& $this->_controller;
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('edit %s'), $this->_document->title));
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_document, $this->_controller->datamanager->schema->name);
     $this->_update_breadcrumb_line('edit');
 }
Example #4
0
 /**
  * Displays an campaign edit view.
  *
  * Note, that the campaign for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation campaign,
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_campaign = $this->_master->load_campaign($args[0]);
     $this->_campaign->require_do('midgard:update');
     $this->set_active_leaf('campaign_' . $this->_campaign->id);
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the campaign
             //$indexer = midcom::get('indexer');
             //org_openpsa_directmarketing_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
             // *** FALL-THROUGH ***
         // Reindex the campaign
         //$indexer = midcom::get('indexer');
         //org_openpsa_directmarketing_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
         // *** FALL-THROUGH ***
         case 'cancel':
             return new midcom_response_relocate("campaign/{$this->_campaign->guid}/");
     }
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/delete/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('delete campaign'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_campaign->can_do('midgard:delete'), MIDCOM_TOOLBAR_ACCESSKEY => 'd'));
     $this->_prepare_request_data($handler_id);
     midcom::get('head')->set_pagetitle($this->_campaign->title);
     $this->bind_view_to_object($this->_campaign, $this->_request_data['controller']->datamanager->schema->name);
     $this->_update_breadcrumb_line($handler_id);
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * Object editing view
  *
  * @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]);
     $this->_object->require_do('midgard:privileges');
     midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin');
     $script = "\n            applyRowClasses();\n        ";
     midcom::get('head')->add_jquery_state_script($script);
     // Load possible additional component privileges
     $this->_load_component_privileges();
     // Load the datamanager controller
     $this->_controller = $this->get_controller('simple', $this->_object);
     if (isset($_POST['midcom_helper_datamanager2_add']) && !empty($_POST['add_assignee'])) {
         $this->_object->set_privilege('midgard:read', $_POST['add_assignee']);
         return new midcom_response_relocate("__mfa/asgard/object/permissions/{$this->_object->guid}/");
     }
     switch ($this->_controller->process_form()) {
         case 'save':
             //Fall-through
         //Fall-through
         case 'cancel':
             return new midcom_response_relocate("__mfa/asgard/object/view/{$this->_object->guid}/");
     }
     $this->_prepare_request_data();
     // Figure out label for the object's class
     switch (get_class($this->_object)) {
         case 'midcom_db_topic':
             $type = midcom::get('i18n')->get_string('folder', 'midgard.admin.asgard');
             break;
         default:
             $type_parts = explode('_', get_class($this->_object));
             $type = $type_parts[count($type_parts) - 1];
     }
     midgard_admin_asgard_plugin::bind_to_object($this->_object, $handler_id, $data);
 }
Example #7
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_create($handler_id, array $args, array &$data)
 {
     $data['directory']->require_do('midgard:create');
     $this->_defaults = array('topic' => $this->_request_data['directory']->id, 'author' => midcom_connection::get_user(), 'orgOpenpsaAccesstype' => $this->_topic->get_parameter('org.openpsa.core', 'orgOpenpsaAccesstype'), 'orgOpenpsaOwnerWg' => $this->_topic->get_parameter('org.openpsa.core', 'orgOpenpsaOwnerWg'));
     $this->_load_create_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             /* Index the document */
             $indexer = new org_openpsa_documents_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             // Relocate to document view
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             if ($this->_document->topic != $this->_topic->id) {
                 $nap = new midcom_helper_nav();
                 $node = $nap->get_node($this->_document->topic);
                 $prefix = $node[MIDCOM_NAV_ABSOLUTEURL];
             }
             return new midcom_response_relocate($prefix . "document/" . $this->_document->guid . "/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_request_data['controller'] =& $this->_controller;
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->add_breadcrumb("", $this->_l10n->get('create document'));
 }
Example #8
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_create($handler_id, array $args, array &$data)
 {
     $data['directory']->require_do('midgard:create');
     $this->_load_create_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Index the directory
             $indexer = new org_openpsa_documents_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             // Relocate to the new directory view
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . $this->_request_data["directory"]->name . "/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_request_data['controller'] = $this->_controller;
     $this->add_breadcrumb("", $this->_l10n->get('new directory'));
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
 }
Example #9
0
 /**
  * Check the edit request
  *
  * @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->_page = $this->_master->load_page($args[0]);
     $this->_page->require_do('midgard:update');
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'preview':
             $this->_preview = true;
             $data['formmanager'] =& $this->_controller->formmanager;
             break;
         case 'save':
             // Reindex the article
             $indexer = midcom::get('indexer');
             net_nemein_wiki_viewer::index($this->_controller->datamanager, $indexer, $this->_topic);
             midcom::get('uimessages')->add($this->_request_data['l10n']->get('net.nemein.wiki'), sprintf($this->_request_data['l10n']->get('page %s saved'), $this->_page->title), 'ok');
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             if ($this->_page->name == 'index') {
                 return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX));
             } else {
                 return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "{$this->_page->name}/");
             }
     }
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_left.png', MIDCOM_TOOLBAR_ACCESSKEY => 'v'));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd', MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:delete')));
     foreach (array_keys($this->_request_data['schemadb']) as $name) {
         if ($name == $this->_controller->datamanager->schema->name) {
             // The page is already of this type, skip
             continue;
         }
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "change/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n->get('change to %s'), $this->_l10n->get($this->_request_data['schemadb'][$name]->description)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_refresh.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('change_to' => $name), MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:update')));
     }
     $this->bind_view_to_object($this->_page, $this->_controller->datamanager->schema->name);
     $data['view_title'] = sprintf($this->_request_data['l10n']->get('edit %s'), $this->_page->title);
     midcom::get('head')->set_pagetitle($data['view_title']);
     // Set the breadcrumb pieces
     $this->add_breadcrumb("{$this->_page->name}/", $this->_page->title);
     $this->add_breadcrumb("edit/{$this->_page->name}/", $this->_l10n_midcom->get('edit'));
     // Set the help object in the toolbar
     $this->_view_toolbar->add_help_item('markdown', 'net.nemein.wiki');
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
 /**
  * @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)
 {
     $data['directory']->require_do('midgard:update');
     $this->_load_edit_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // TODO: Update the URL name?
             // Update the Index
             $indexer = new org_openpsa_documents_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             $this->_view = "default";
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX));
         case 'cancel':
             $this->_view = "default";
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX));
     }
     $this->_request_data['controller'] = $this->_controller;
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get('directory')));
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_request_data['directory'], $this->_controller->datamanager->schema->name);
 }
Example #12
0
 /**
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_create($handler_id, array $args, array &$data)
 {
     $this->_dbaclass = $args[0];
     midcom::get('auth')->require_user_do('midgard:create', null, $this->_dbaclass);
     $this->_load_component_node();
     $this->_controller = $this->get_controller('create');
     switch ($this->_controller->process_form()) {
         case 'save':
             $this->_post_create_actions();
             //TODO: indexing
             $this->_action = 'save';
             break;
         case 'cancel':
             $this->_action = 'cancel';
             break;
     }
     $data['controller'] =& $this->_controller;
     $data['action'] =& $this->_action;
     midcom::get()->skip_page_style = true;
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
 }
Example #13
0
 /**
  * Displays a deliverable edit view.
  *
  * Note, that the deliverable for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation deliverable
  *
  * @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->_deliverable = new org_openpsa_sales_salesproject_deliverable_dba($args[0]);
     $this->_deliverable->require_do('midgard:update');
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             $formdata = $this->_controller->datamanager->types;
             if (!empty($formdata['at_entry']->value)) {
                 $entry = new midcom_services_at_entry_dba((int) $formdata['at_entry']->value);
                 $next_cycle = 0;
                 if (isset($formdata['next_cycle']) && !$formdata['next_cycle']->is_empty()) {
                     $next_cycle = (int) $formdata['next_cycle']->value->format('U');
                 }
                 //@todo If next_cycle is changed to be in the past, should we check if this would lead
                 //to multiple runs immediately? i.e. if you set a monthly subscriptions next cycle to
                 //one year in the past, this would trigger twelve consecutive runs and maybe
                 //the user needs to be warned about that...
                 if ($next_cycle != $entry->start) {
                     $entry->start = $next_cycle;
                     $entry->update();
                 }
             }
             $this->_master->process_notify_date($formdata, $this->_deliverable);
             // Reindex the deliverable
             //$indexer = midcom::get('indexer');
             //org_openpsa_sales_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
             // *** FALL-THROUGH ***
         // Reindex the deliverable
         //$indexer = midcom::get('indexer');
         //org_openpsa_sales_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
         // *** FALL-THROUGH ***
         case 'cancel':
             return new midcom_response_relocate("deliverable/{$this->_deliverable->guid}/");
     }
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_prepare_request_data($handler_id);
     $this->bind_view_to_object($this->_deliverable, $this->_request_data['controller']->datamanager->schema->name);
     $this->_update_breadcrumb_line($handler_id);
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('edit %s'), $this->_deliverable->title));
 }
Example #14
0
 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();");
 }
Example #15
0
 /**
  * Displays a contact edit view.
  *
  * Note, that the contact for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation contact
  *
  * @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->_contact = new org_openpsa_contacts_person_dba($args[0]);
     $this->_contact->require_do('midgard:update');
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the contact
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($this->_controller->datamanager);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             return new midcom_response_relocate("person/{$this->_contact->guid}/");
     }
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_prepare_request_data($handler_id);
     midcom::get('head')->set_pagetitle($this->_contact->name);
     $this->bind_view_to_object($this->_contact, $this->_controller->datamanager->schema->name);
     $this->_update_breadcrumb_line($handler_id);
 }
Example #16
0
 /**
  * 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);
 }
Example #17
0
 /**
  * @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_new($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     midcom::get('auth')->require_user_do('midgard:create', null, 'org_openpsa_sales_salesproject_dba');
     $this->_defaults['code'] = org_openpsa_sales_salesproject_dba::generate_salesproject_number();
     $this->_defaults['owner'] = midcom_connection::get_user();
     if (!isset($this->_datamanager)) {
         $this->_initialize_datamanager($this->_config->get('schemadb_salesproject'));
     }
     $this->_load_create_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Relocate to main view
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             return new midcom_response_relocate($prefix . "salesproject/edit/" . $this->_salesproject->guid . "/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_request_data['controller'] =& $this->_controller;
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('salesproject')));
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
 }