/** * DM2 creation callback, binds to the current content topic. */ public function &dm2_create_callback(&$controller) { $this->_campaign = new org_openpsa_directmarketing_campaign_dba(); $this->_campaign->node = $this->_topic->id; if (!$this->_campaign->create()) { debug_print_r('We operated on this object:', $this->_campaign); throw new midcom_error('Failed to create a new campaign. Last Midgard error was: ' . midcom_connection::get_error_string()); } return $this->_campaign; }
private function _populate_toolbar() { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/edit/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit campaign'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e', MIDCOM_TOOLBAR_ENABLED => $this->_campaign->can_do('midgard:update'))); $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_ACCESSKEY => 'd', MIDCOM_TOOLBAR_ENABLED => $this->_campaign->can_do('midgard:delete'))); if ($this->_campaign->orgOpenpsaObtype == org_openpsa_directmarketing_campaign_dba::TYPE_SMART) { //Edit query parameters button in case 1) not in edit mode 2) is smart campaign 3) can edit $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/edit_query/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit rules'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/repair.png', MIDCOM_TOOLBAR_ENABLED => $this->_campaign->can_do('midgard:update'))); } else { // Import button if we have permissions to create users $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/import/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('import subscribers'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba'))); } $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/export/csv/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('export as csv'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_data-edit-table.png')); }
/** * Displays an campaign delete confirmation 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_delete($handler_id, array $args, array &$data) { $this->_campaign = $this->_master->load_campaign($args[0]); $this->_campaign->require_do('midgard:delete'); $this->_load_datamanager(); if (array_key_exists('org_openpsa_directmarketing_deleteok', $_REQUEST)) { // Deletion confirmed. if (!$this->_campaign->delete()) { throw new midcom_error("Failed to delete campaign {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string()); } // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_campaign->guid); // Delete ok, relocating to welcome. return new midcom_response_relocate(''); } if (array_key_exists('org_openpsa_directmarketing_deletecancel', $_REQUEST)) { // Redirect to view page. return new midcom_response_relocate("campaign/{$this->_campaign->guid}/"); } $this->set_active_leaf('campaign_' . $this->_campaign->id); $this->_prepare_request_data($handler_id); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/edit/{$this->_campaign->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit campaign'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_campaign->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); midcom::get('head')->set_pagetitle($this->_campaign->title); $this->bind_view_to_object($this->_campaign, $this->_datamanager->schema->name); $this->_update_breadcrumb_line($handler_id); }