Exemplo n.º 1
0
 /**
  * DM2 creation callback, binds to the current content topic.
  */
 public function &dm2_create_callback(&$controller)
 {
     $this->_message = new org_openpsa_directmarketing_campaign_message_dba();
     //  duh ? (copy-paste artefact ??)
     $this->_message->campaign = $this->_request_data['campaign']->id;
     $this->_message->orgOpenpsaObtype = $this->_schemadb[$this->_schema]->customdata['org_openpsa_directmarketing_messagetype'];
     if (!$this->_message->create()) {
         debug_print_r('We operated on this object:', $this->_message);
         throw new midcom_error('Failed to create a new message. Last Midgard error was: ' . midcom_connection::get_error_string());
     }
     return $this->_message;
 }
Exemplo n.º 2
0
 /**
  * Displays an message delete confirmation view.
  *
  * Note, that the message for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation message,
  */
 public function _handler_delete($handler_id, array $args, array &$data)
 {
     $this->_message = new org_openpsa_directmarketing_campaign_message_dba($args[0]);
     $this->_message->require_do('midgard:delete');
     $data['campaign'] = new org_openpsa_directmarketing_campaign_dba($this->_message->campaign);
     $this->set_active_leaf('campaign_' . $data['campaign']->id);
     $this->_load_datamanager();
     if (array_key_exists('org_openpsa_directmarketing_deleteok', $_REQUEST)) {
         // Deletion confirmed.
         if (!$this->_message->delete()) {
             throw new midcom_error("Failed to delete message {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string());
         }
         // Update the index
         $indexer = midcom::get('indexer');
         $indexer->delete($this->_message->guid);
         // Delete ok, relocating to welcome.
         return new midcom_response_relocate("campaign/{$data['campaign']->guid}/");
     }
     if (array_key_exists('org_openpsa_directmarketing_deletecancel', $_REQUEST)) {
         // Redirect to view page.
         return new midcom_response_relocate("message/{$this->_message->guid}/");
     }
     $this->_prepare_request_data($handler_id);
     midcom::get('head')->set_pagetitle($this->_message->title);
     $this->bind_view_to_object($this->_message, $this->_datamanager->schema->name);
     $this->_update_breadcrumb_line($handler_id);
 }
Exemplo n.º 3
0
 private function _populate_toolbar()
 {
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/edit/{$this->_message->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit message'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e', MIDCOM_TOOLBAR_ENABLED => $this->_message->can_do('midgard:update')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/delete/{$this->_message->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('delete message'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd', MIDCOM_TOOLBAR_ENABLED => $this->_message->can_do('midgard:delete')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/copy/{$this->_message->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('copy message'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/editcopy.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e', MIDCOM_TOOLBAR_ENABLED => $this->_message->can_do('midgard:update')));
     if (!empty(midcom::get('auth')->user->guid)) {
         $preview_url = "message/compose/{$this->_message->guid}/" . midcom::get('auth')->user->guid . '/';
     } else {
         $preview_url = "message/compose/{$this->_message->guid}/";
     }
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $preview_url, MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('preview message'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/view.png', MIDCOM_TOOLBAR_ACCESSKEY => 'p', MIDCOM_TOOLBAR_OPTIONS => array('target' => '_BLANK')));
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/report/{$this->_request_data['message']->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("message report"), MIDCOM_TOOLBAR_ACCESSKEY => 'r', MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/printer.png'));
     $this->_campaign->get_testers();
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/send_test/{$this->_request_data['message']->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("send message to testers"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail-send.png', MIDCOM_TOOLBAR_ENABLED => count($this->_campaign->testers) > 0 ? true : false));
     $mc = org_openpsa_campaign_member::new_collector('campaign', $this->_campaign->id);
     $mc->set_key_property('campaign');
     $mc->execute();
     $keys = $mc->list_keys();
     // Show the message send if there are recipients
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "message/send/{$this->_request_data['message']->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("send message to whole campaign"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail-send.png', MIDCOM_TOOLBAR_ENABLED => count($keys) > 0 && $this->_message->can_do('midgard:update') ? true : false, MIDCOM_TOOLBAR_OPTIONS => array('onclick' => "return confirm('" . $this->_l10n->get('are you sure you wish to send this to the whole campaign') . "')")));
 }