Example #1
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();
     // Check if we get the group
     $this->_group = new org_openpsa_contacts_group_dba($args[0]);
     $this->_group->require_do('midgard:update');
     if ($this->_group->orgOpenpsaObtype < org_openpsa_contacts_group_dba::MYCONTACTS) {
         $this->_type = 'group';
     } else {
         $this->_type = 'organization';
     }
     $data['controller'] = $this->get_controller('simple', $this->_group);
     switch ($data['controller']->process_form()) {
         case 'save':
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($data['controller']->datamanager);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
             return new midcom_response_relocate($prefix . "group/" . $this->_group->guid . "/");
     }
     $root_group = org_openpsa_contacts_interface::find_root_group();
     if ($this->_group->owner && $this->_group->owner != $root_group->id) {
         $data['parent_group'] = new org_openpsa_contacts_group_dba($this->_group->owner);
     } else {
         $data['parent_group'] = false;
     }
     $data['group'] =& $this->_group;
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_group);
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get('edit %s'), $this->_group->official));
     org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_group, $this);
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('edit %s'), $this->_l10n->get($this->_type)));
 }
Example #2
0
 /**
  * Method for adding the supported operations into the toolbar.
  *
  * @param mixed $handler_id The ID of the handler.
  */
 public function _populate_toolbar($handler_id)
 {
     if ($this->_mode == 'create' || $this->_mode == 'update') {
         org_openpsa_helpers::dm2_savecancel($this);
     } else {
         if ($this->_mode == 'delete') {
             org_openpsa_helpers::dm2_savecancel($this, 'delete');
         }
     }
     if ($this->_mode == 'create') {
         return;
     }
     $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/edit/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e'));
     if ($this->_object->reportedHours == 0) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/delete/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:delete'), MIDCOM_TOOLBAR_ACCESSKEY => 'd'));
     }
     if ($this->_mode == 'read') {
         $this->_populate_read_toolbar($handler_id);
     }
     switch ($handler_id) {
         case 'task_edit':
             $this->_view_toolbar->disable_item("task/edit/{$this->_object->guid}/");
             break;
         case 'task_delete':
             $this->_view_toolbar->disable_item("task/delete/{$this->_object->guid}/");
             break;
     }
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * Handle the creation 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_create($handler_id, array $args, array &$data)
 {
     // Get the root event
     $this->_root_event = org_openpsa_calendar_interface::find_root_event();
     // ACL handling: require create privileges
     $this->_root_event->require_do('midgard:create');
     if (isset($args[0])) {
         $this->_person = new midcom_db_person($args[0]);
     }
     if (isset($args[1])) {
         $this->_requested_time = (int) $args[1];
     }
     // Load the controller instance
     $data['controller'] = $this->get_controller('create');
     // Process form
     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();');
             break;
     }
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     // Hide the ROOT style
     midcom::get()->skip_page_style = true;
 }
Example #6
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)
 {
     midcom::get('auth')->require_valid_user();
     midcom::get('auth')->require_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba');
     if (count($args) > 0) {
         // Get the organization
         $this->_group = new org_openpsa_contacts_group_dba($args[0]);
         $this->_group->require_do('midgard:create');
         midcom::get('head')->set_pagetitle($this->_group->official);
     }
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             // Index the person
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($data['controller']->datamanager);
             return new midcom_response_relocate("person/{$this->_person->guid}/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_group, $this);
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('person')));
 }
Example #7
0
 /**
  * Method for adding the supported operations into the toolbar.
  *
  * @param mixed $handler_id The ID of the handler.
  */
 public function _populate_toolbar($handler_id)
 {
     if ($this->_mode == 'create' || $this->_mode == 'update') {
         org_openpsa_helpers::dm2_savecancel($this);
     } else {
         if ($this->_mode == 'read') {
             $this->_add_read_toolbar($handler_id);
         }
     }
 }
Example #8
0
 public function _populate_toolbar($handler_id)
 {
     if ($this->_mode == 'delete') {
         org_openpsa_helpers::dm2_savecancel($this, 'delete');
     }
     if ($this->_object->can_do('midgard:update')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "productlink/edit/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e'));
     }
     if ($this->_object->can_do('midgard:delete')) {
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "productlink/delete/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd'));
     }
 }
Example #9
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)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), sprintf($this->_l10n->get('group %s saved'), $this->_group->name));
             return new midcom_response_relocate('group/' . $this->_group->guid);
         case 'cancel':
             return new midcom_response_relocate('groups/');
     }
     $this->add_breadcrumb('groups/', $this->_l10n->get('groups'));
     $this->add_breadcrumb('', sprintf($this->_l10n->get('create group')));
     org_openpsa_helpers::dm2_savecancel($this);
 }
Example #10
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_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     $this->_group = new midcom_db_group($args[0]);
     $data['controller'] = $this->get_controller('simple', $this->_group);
     switch ($data['controller']->process_form()) {
         case 'save':
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), sprintf($this->_l10n->get('group %s saved'), $this->_group->get_label()));
             // Fall-through
         // Fall-through
         case 'cancel':
             return new midcom_response_relocate('group/' . $this->_group->guid . '/');
     }
     $this->add_breadcrumb('groups/', $this->_l10n->get('groups'));
     $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('edit %s'), $this->_group->get_label()));
     org_openpsa_helpers::dm2_savecancel($this);
     $this->bind_view_to_object($this->_group);
 }
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_notifications($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     $person = new org_openpsa_contacts_person_dba($args[0]);
     $person->require_do('midgard:update');
     $controller = $this->get_controller('simple', $person);
     switch ($controller->process_form()) {
         case 'save':
             // Fall-through
         // Fall-through
         case 'cancel':
             return new midcom_response_relocate("view/" . $person->guid . "/");
     }
     $data['notifications_dm'] =& $controller;
     $data['object'] = $person;
     midcom::get('head')->set_pagetitle($person->get_label() . ": " . $this->_l10n->get("notification settings"));
     $this->add_breadcrumb('view/' . $person->guid . '/', $person->get_label());
     $this->add_breadcrumb("", $this->_l10n->get("notification settings"));
     org_openpsa_helpers::dm2_savecancel($this);
 }
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_privileges($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     // Check if we get the group
     $this->_group = new midcom_db_group($args[0]);
     $this->_group->require_do('midgard:privileges');
     $data['group'] = $this->_group;
     $data['acl_dm'] = $this->get_controller('simple', $this->_group);
     switch ($data['acl_dm']->process_form()) {
         case 'save':
             // Fall-through
         // Fall-through
         case 'cancel':
             return new midcom_response_relocate(midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "group/" . $this->_group->guid . "/");
     }
     midcom::get('head')->set_pagetitle($this->_group->official);
     org_openpsa_helpers::dm2_savecancel($this);
     $this->add_breadcrumb("group/{$this->_group->guid}/", $this->_group->name);
     $this->add_breadcrumb("", $this->_l10n->get('permissions'));
 }
Example #13
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 #14
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)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     if (count($args) > 0) {
         // Get the organization
         $this->_group = new midcom_db_group($args[0]);
         $this->_group->require_do('midgard:create');
         midcom::get('head')->set_pagetitle($this->_group->official);
         $this->add_breadcrumb('group/' . $this->_group->guid . '/', $this->_group->get_label());
     }
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), sprintf($this->_l10n->get('person %s created'), $this->_person->name));
             $this->_master->create_account($this->_person, $data["controller"]->formmanager);
             return new midcom_response_relocate('view/' . $this->_person->guid . '/');
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->add_breadcrumb('', sprintf($this->_l10n->get('create person')));
     org_openpsa_helpers::dm2_savecancel($this);
 }
Example #15
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 #16
0
 private function _prepare_output($mode)
 {
     midcom::get('head')->enable_jquery();
     midcom::get('head')->set_pagetitle(sprintf($this->_l10n_midcom->get($mode . " %s"), $this->_l10n->get("billing data")));
     $this->_update_breadcrumb();
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_request_data['controller'] =& $this->_controller;
 }
    $paid = ", " . midcom::get('i18n')->get_string('paid', 'org.openpsa.invoices') . ": " . strftime('%x', $invoice->paid);
} else {
    if ($invoice->due < time()) {
        $paid = ", " . midcom::get('i18n')->get_string('not paid', 'org.openpsa.invoices');
    }
}
?>

<li class="invoice" id="org_openpsa_relatedto_line_&(link['guid']);">
    <span class="icon">&(data['icon']:h);</span>
    <span class="title">&(data['title']:h);</span>
    <ul class="metadata">
    <?php 
// Customer
if ($invoice->customer) {
    $customer = midcom_db_group::get_cached($invoice->customer);
    echo "<li>" . midcom::get('i18n')->get_string('customer', 'org.openpsa.invoices') . ": {$customer->official}</li>";
}
echo "<li>" . midcom::get('i18n')->get_string('sum', 'org.openpsa.invoices') . ": " . org_openpsa_helpers::format_number($invoice->sum) . " (" . midcom::get('i18n')->get_string('due', 'org.openpsa.invoices') . ": " . strftime('%x', $invoice->due) . "{$paid})</li>";
?>
    </ul>

    <div id="org_openpsa_relatedto_details_&(invoice.guid);" class="details hidden" style="display: none;">
    </div>

  <?php 
//TODO: necessary JS stuff to load details (which should in turn include the invoice's own relatedtos) via AHAH
echo org_openpsa_relatedto_handler_relatedto::render_line_controls($link, $data['other_obj']);
?>
</li>
Example #18
0
</td>
                              <td class="numeric"><?php 
    echo org_openpsa_helpers::format_number($view['cost']);
    ?>
</td>
                          <?php 
} else {
    ?>
                              <td class="numeric"><?php 
    echo $view['costPerUnit'];
    ?>
 %</td>
                              <td class="numeric">&nbsp;</td>
                              <td class="numeric">&nbsp;</td>
                              <td class="numeric"><?php 
    echo org_openpsa_helpers::format_number($view['cost']);
    ?>
</td>
                          <?php 
}
?>
                        </tr>
                      </tbody>
                    </table>
                    </td>
                </tr>
            <tbody>
        </table>
    </div>

    <div class="wide">
Example #19
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 #20
0
 function _populate_toolbar($handler_id)
 {
     if ($this->_mode == 'update' || $this->_mode == 'create') {
         // Add toolbar items
         org_openpsa_helpers::dm2_savecancel($this);
     } else {
         if ($this->_mode == 'delete') {
             org_openpsa_helpers::dm2_savecancel($this, 'delete');
         }
     }
     if ($this->_mode == 'read') {
         $this->_populate_read_toolbar($handler_id);
     }
 }
<?php

if (isset($_POST['midcom_helper_datamanager_dummy_field_rules'])) {
    $editor_content = $_POST['midcom_helper_datamanager_dummy_field_rules'];
} else {
    $editor_content = org_openpsa_helpers::array2code($data['campaign']->rules);
}
?>
<div class="main">
    <form name="org_openpsa_directmarketing_rules_advanced_editor" enctype="multipart/form-data" method="post" class="datamanager2">
        <fieldset class="area">
            <legend><?php 
echo $data['l10n']->get('edit rules');
?>
</legend>
            <label for="midcom_helper_datamanager2_dummy_field_rules" id="midcom_helper_datamanager2_dummy_field_rules_label">
                <textarea id="midcom_helper_datamanager2_dummy_field_rules" name="midcom_helper_datamanager2_dummy_field_rules" rows="25" cols="50" class="longtext" >&(editor_content);</textarea>
            </label>
        </fieldset>
        <div class="form_toolbar">
            <input name="midcom_helper_datamanager2_save" accesskey="s" class="save" value="<?php 
echo $data['l10n_midcom']->get('save');
?>
" type="submit" />
            <input name="midcom_helper_datamanager2_cancel" class="cancel" value="<?php 
echo $data['l10n_midcom']->get('cancel');
?>
" type="submit" />
        </div>
    </form>
</div>
Example #22
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)
 {
     midcom::get('auth')->require_valid_user();
     $this->_type = $args[0];
     $this->_parent_group = false;
     if (count($args) > 1) {
         // Get the parent organization
         $this->_parent_group = new org_openpsa_contacts_group_dba($args[1]);
         $this->_parent_group->require_do('midgard:create');
     } else {
         // This is a root level organization, require creation permissions under the component root group
         midcom::get('auth')->require_user_do('midgard:create', null, 'org_openpsa_contacts_group_dba');
     }
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             // Index the organization
             $indexer = new org_openpsa_contacts_midcom_indexer($this->_topic);
             $indexer->index($data['controller']->datamanager);
             // Relocate to group view
             return new midcom_response_relocate("group/" . $this->_group->guid . "/");
         case 'cancel':
             if ($this->_parent_group) {
                 return new midcom_response_relocate("group/" . $this->_parent_group->guid . "/");
             } else {
                 return new midcom_response_relocate('');
             }
     }
     $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css");
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     midcom::get('head')->set_pagetitle($this->_l10n->get("create organization"));
     org_openpsa_contacts_viewer::add_breadcrumb_path_for_group($this->_parent_group, $this);
     $this->add_breadcrumb("", sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($this->_type)));
 }
Example #23
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_create($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_user_do('midgard:create', null, 'org_openpsa_directmarketing_campaign_dba');
     $this->_schema = $args[0];
     $this->load_schemadb();
     if (!array_key_exists($this->_schema, $this->_schemadb)) {
         throw new midcom_error_notfound('The campaign type ' . $this->_schema . 'isn\'t available in the schemadb');
     }
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             // Index the campaign
             //$indexer = midcom::get('indexer');
             //org_openpsa_directmarketing_viewer::index($data['controller']->datamanager, $indexer, $this->_topic);
             return new midcom_response_relocate("campaign/{$this->_campaign->guid}/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     if ($this->_campaign != null) {
         midcom::get('metadata')->set_request_metadata($this->_campaign->metadata->revised, $this->_campaign->guid);
     }
     $data['view_title'] = sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($this->_schemadb[$this->_schema]->description));
     midcom::get('head')->set_pagetitle($data['view_title']);
     $this->add_breadcrumb("create/{$this->_schema}/", sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($this->_schemadb[$this->_schema]->description)));
     org_openpsa_helpers::dm2_savecancel($this);
 }
            <th><?php 
echo $l10n->get('% of clicks');
?>
</th>
            <th><?php 
echo $l10n->get('% of recipients');
?>
</th>
        </tr>
        <?php 
$total = 0;
foreach ($link_data['counts'] as $target => $count) {
    $total += $count;
    $of_clicks = $link_data['percentages']['of_links'][$target];
    $of_recipients = $link_data['percentages']['of_recipients'][$target];
    $rule_ser = org_openpsa_helpers::array2code($link_data['rules'][$target]);
    $visual_width = round($of_clicks * 5);
    $target_label = $target;
    // Fetch target url and look for a heading to use
    //TODO: Make a HEAD request and check the content-type in stead fo trying to guess here
    if (preg_match('/(\\.html?|\\/|\\.com|\\.net|\\.org|\\.fi|\\.info)$/', trim(urldecode($target)))) {
        debug_add("Trying to fetch '{$target}' and read title from there");
        $remote_data = false;
        $fp = @fopen(trim(urldecode($target)), 'r');
        if ($fp) {
            while (!feof($fp)) {
                $remote_data .= fread($fp, 4096);
            }
            fclose($fp);
            $regexs = array("/(<h([1-3])>)(.*?)(<\\/h\\2>)/msi", "/(<meta name=['\"].*?title['\"] content=(['\"]))(.*?)\\2(\\/>)/msi", "/((<title>))(.*?)(<\\/title>)/msi");
            foreach ($regexs as $regex) {
Example #25
0
 private function _send_by_mail(org_openpsa_invoices_invoice_dba $invoice)
 {
     $customerCard = org_openpsa_widgets_contact::get($invoice->customerContact);
     $contactDetails = $customerCard->contact_details;
     $invoice_label = $invoice->get_label();
     $invoice_date = date($this->_l10n_midcom->get('short date'), $invoice->date);
     // generate pdf, only if not existing yet
     $pdf_files = org_openpsa_helpers::get_attachment_urls($invoice, "pdf_file");
     if (count($pdf_files) == 0) {
         org_openpsa_invoices_handler_pdf::render_and_attach_pdf($invoice);
     }
     $mail = new org_openpsa_mail();
     // define replacements for subject / body
     $mail->parameters = array("INVOICE_LABEL" => $invoice_label, "INVOICE_DATE" => $invoice_date, "FIRSTNAME" => $contactDetails["firstname"], "LASTNAME" => $contactDetails["lastname"]);
     $mail->to = $contactDetails["email"];
     $mail->from = $this->_config->get('invoice_mail_from_address');
     $mail->subject = $this->_config->get('invoice_mail_title');
     $mail->body = $this->_config->get('invoice_mail_body');
     // attach pdf to mail
     if ($mail->can_attach()) {
         $pdf_files = org_openpsa_helpers::get_attachment_urls($invoice, "pdf_file");
         if (count($pdf_files) > 0) {
             foreach ($pdf_files as $guid => $url) {
                 $att = array();
                 $att['name'] = basename($url) . ".pdf";
                 $att['mimetype'] = "application/pdf";
                 $fp = fopen($url, "r");
                 if (!$fp) {
                     //Failed to open attachment for reading, skip the file
                     continue;
                 }
                 $att['content'] = '';
                 while (!feof($fp)) {
                     $att['content'] .= fread($fp, 4096);
                 }
                 fclose($fp);
                 debug_add("adding attachment '{$att['name']}' to attachments array of invoice mail");
                 $mail->attachments[] = $att;
                 unset($att);
             }
         }
     }
     if (!$mail->send()) {
         $this->_request_data['message']['message'] = sprintf($this->_l10n->get('unable to deliver mail: %s'), $mail->get_error_message());
         return false;
     } else {
         $invoice->set_parameter($this->_component, 'sent_by_mail', time());
         return $this->_mark_as_sent($invoice);
     }
 }
Example #26
0
 /**
  * Displays an message edit 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_edit($handler_id, array $args, array &$data)
 {
     $this->_message = new org_openpsa_directmarketing_campaign_message_dba($args[0]);
     $this->_message->require_do('midgard:update');
     $data['campaign'] = new org_openpsa_directmarketing_campaign_dba($this->_message->campaign);
     $this->set_active_leaf('campaign_' . $data['campaign']->id);
     $this->_load_controller();
     $data['message_dm'] =& $this->_controller;
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the message
             //$indexer = midcom::get('indexer');
             //org_openpsa_directmarketing_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
             // *** FALL-THROUGH ***
         // Reindex the message
         //$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("message/{$this->_message->guid}/");
     }
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_prepare_request_data($handler_id);
     midcom::get('head')->set_pagetitle($this->_message->title);
     $this->bind_view_to_object($this->_message, $this->_request_data['controller']->datamanager->schema->name);
     $this->_update_breadcrumb_line($handler_id);
 }
Example #27
0
 public static function render_and_attach_pdf(org_openpsa_invoices_invoice_dba $invoice)
 {
     if ($invoice->date == 0 || $invoice->deliverydate == 0) {
         $time = time();
         if ($invoice->date == 0) {
             $invoice->date = $time;
         }
         if ($invoice->deliverydate == 0) {
             $invoice->deliverydate = $time;
         }
         $invoice->update();
     }
     // renders the pdf and attaches it to the invoice
     $client_class = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config')->get('invoice_pdfbuilder_class');
     if (!class_exists($client_class)) {
         debug_add('Could not find PDF renderer, aborting silently', MIDCOM_LOG_INFO);
         return false;
     }
     $pdf_builder = new $client_class($invoice);
     // tmp filename
     $tmp_dir = $GLOBALS["midcom_config"]["midcom_tempdir"];
     $title = str_replace("#", "", $invoice->get_label());
     $tmp_file = $tmp_dir . "/" . $title . ".pdf";
     // render pdf to tmp filename
     $render = $pdf_builder->render($tmp_file);
     // cleanup old attachments
     $pdf_files = org_openpsa_helpers::get_attachment_urls($invoice, "pdf_file");
     if (count($pdf_files) > 0) {
         foreach ($pdf_files as $guid => $url) {
             $attachment = new midcom_db_attachment($guid);
             $attachment->delete();
         }
     }
     $attachment = $invoice->create_attachment($title . '.pdf', $title, "application/pdf");
     if (!$attachment) {
         debug_add("Failed to create invoice attachment for pdf", MIDCOM_LOG_ERROR);
         return false;
     }
     $copy = $attachment->copy_from_file($tmp_file);
     if (!$copy) {
         debug_add("Failed to copy pdf from " . $tmp_file . " to attachment", MIDCOM_LOG_ERROR);
         return false;
     }
     // set parameter for datamanager to find the pdf
     if (!$invoice->set_parameter("midcom.helper.datamanager2.type.blobs", "guids_pdf_file", $attachment->guid . ":" . $attachment->guid) || !$attachment->set_parameter('org.openpsa.invoices', 'auto_generated', md5_file($tmp_file))) {
         debug_add("Failed to create attachment parameters, last midgard error was: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         return false;
     }
     return true;
 }
Example #28
0
        continue;
    }
    $view_product = $data['datamanager_product']->get_content_html();
    $entry = array();
    $path = $product->get_path();
    $link_html = "<a href='{$prefix}product/{$path}/'>";
    $next_marker = false;
    $entry['id'] = $product->id;
    $entry['index_code'] = $product->code;
    $entry['code'] = $link_html . $product->code . '</a>';
    $entry['index_title'] = $product->title;
    $entry['title'] = $link_html . $product->title . '</a>';
    $entry['orgOpenpsaObtype'] = $view_product['orgOpenpsaObtype'];
    $entry['delivery'] = $view_product['delivery'];
    $entry['index_price'] = $product->price;
    $entry['price'] = org_openpsa_helpers::format_number($product->price);
    $entry['unit'] = $view_product['unit'];
    $entries[] = $entry;
}
echo '<script type="text/javascript">//<![CDATA[';
echo "\nvar " . $grid_id . '_entries = ' . json_encode($entries);
echo "\n//]]></script>";
?>

<div class="org_openpsa_products full-width">

<table id="&(grid_id);"></table>
<div id="p_&(grid_id);"></div>

</div>
Example #29
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 #30
0
 /**
  * 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_add($handler_id, array $args, array &$data)
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         throw new midcom_error_forbidden('Only POST requests are allowed here.');
     }
     $this->_salesproject = new org_openpsa_sales_salesproject_dba($args[0]);
     $this->_salesproject->require_do('midgard:create');
     if (!array_key_exists('product', $_POST)) {
         throw new midcom_error('No product specified, aborting.');
     }
     $this->_product = new org_openpsa_products_product_dba((int) $_POST['product']);
     $this->_prepare_datamanager();
     $data['controller'] = $this->_controller;
     // Process form
     switch ($data['controller']->process_form()) {
         case 'save':
             $formdata = $data['controller']->datamanager->types;
             $this->_master->process_notify_date($formdata, $this->_deliverable);
         case 'cancel':
             return new midcom_response_relocate("salesproject/{$this->_salesproject->guid}/");
     }
     org_openpsa_helpers::dm2_savecancel($this);
     $this->add_breadcrumb("salesproject/{$this->_salesproject->guid}/", $this->_salesproject->title);
     $this->add_breadcrumb('', $this->_l10n->get('add offer'));
 }