Example #1
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 #2
0
 private function _load_datamanager()
 {
     $schemadb_person = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person'));
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($schemadb_person);
     $this->_datamanager->set_schema($this->_master->get_person_schema($this->_contact));
     $this->_datamanager->set_storage($this->_contact);
 }
Example #3
0
 /**
  * Load either a create controller or an edit (simple) controller or trigger an error message
  */
 private function _load_controller()
 {
     // Get the configured schemas
     $schemadbs = $this->_config->get('schemadbs_folder');
     // Check if a custom schema exists
     if (array_key_exists($this->_topic->component, $schemadbs)) {
         $schemadb = $schemadbs[$this->_topic->component];
     } else {
         if (!array_key_exists('default', $schemadbs)) {
             throw new midcom_error('Configuration error. No default schema for topic has been defined!');
         }
         $schemadb = $schemadbs['default'];
     }
     $GLOBALS['midcom_admin_folder_mode'] = $this->_handler_id;
     // Create the schema instance
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb);
     switch ($this->_handler_id) {
         case 'edit':
             $this->_controller = midcom_helper_datamanager2_controller::create('simple');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->set_storage($this->_topic);
             break;
         case 'create':
             foreach ($this->_schemadb as $schema) {
                 if (isset($schema->fields['name'])) {
                     $schema->fields['name']['required'] = 0;
                 }
             }
             $this->_controller = midcom_helper_datamanager2_controller::create('create');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->schemaname = 'default';
             $this->_controller->callback_object =& $this;
             // Suggest to create the same type of a folder as the parent is
             $component_suggestion = $this->_topic->component;
             //Unless config told us otherwise
             if ($this->_config->get('default_component')) {
                 $component_suggestion = $this->_config->get('default_component');
             }
             $this->_controller->defaults = array('component' => $component_suggestion);
             break;
         case 'createlink':
             if (!array_key_exists('link', $schemadbs)) {
                 throw new midcom_error('Configuration error. No link schema for topic has been defined!');
             }
             $schemadb = $schemadbs['link'];
             // Create the schema instance
             $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb);
             $this->_schemadb->default->fields['name']['required'] = 0;
             $this->_controller = midcom_helper_datamanager2_controller::create('create');
             $this->_controller->schemadb =& $this->_schemadb;
             $this->_controller->schemaname = 'link';
             $this->_controller->callback_object =& $this;
             break;
         default:
             throw new midcom_error('Unable to process the request, unknown handler id');
     }
     if (!$this->_controller->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_event->id}.");
     }
 }
Example #4
0
 /**
  * Loads and prepares the schema database.
  *
  * The operations are done on all available schemas within the DB.
  */
 public function load_schemadb()
 {
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_acl'));
     $fields =& $schemadb['default']->fields;
     $group_object = midcom::get('auth')->get_group("group:{$this->_request_data['group']->guid}");
     // Get the calendar root event
     $root_event = org_openpsa_calendar_interface::find_root_event();
     if (is_object($root_event)) {
         $fields['calendar']['privilege_object'] = $root_event;
         $fields['calendar']['privilege_assignee'] = $group_object->id;
     } else {
         if (isset($fields['calendar'])) {
             unset($fields['calendar']);
         }
     }
     // Set the group into ACL
     $fields['contact_creation']['privilege_object'] = $group_object->get_storage();
     $fields['contact_editing']['privilege_object'] = $group_object->get_storage();
     $fields['organization_creation']['privilege_object'] = $group_object->get_storage();
     $fields['organization_editing']['privilege_object'] = $group_object->get_storage();
     $fields['projects']['privilege_object'] = $group_object->get_storage();
     $fields['invoices_creation']['privilege_object'] = $group_object->get_storage();
     $fields['invoices_editing']['privilege_object'] = $group_object->get_storage();
     // Load campaign classes
     if (midcom::get('componentloader')->load_graceful('org.openpsa.directmarketing')) {
         $fields['campaigns_creation']['privilege_object'] = $group_object->get_storage();
         $fields['campaigns_editing']['privilege_object'] = $group_object->get_storage();
     } else {
         unset($fields['campaigns_creation']);
         unset($fields['campaigns_editing']);
     }
     $fields['salesproject_creation']['privilege_object'] = $group_object->get_storage();
     return $schemadb;
 }
Example #5
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_list($handler_id, array &$data)
 {
     if ($handler_id == 'mycontacts_xml') {
         $schemadb_person = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person'));
         $datamanager = new midcom_helper_datamanager2_datamanager($schemadb_person);
         $xml = '<contacts></contacts>';
         $simplexml = simplexml_load_string($xml);
         foreach ($data['mycontacts'] as $person) {
             $contact = $simplexml->addChild('contact');
             $contact->addAttribute('guid', $person->guid);
             $datamanager->autoset_storage($person);
             $person_data = $datamanager->get_content_xml();
             foreach ($person_data as $key => $value) {
                 $contact->addChild($key, $value);
             }
             $mc = midcom_db_member::new_collector('uid', $person->id);
             $memberships = $mc->get_values('gid');
             $qb = org_openpsa_contacts_group_dba::new_query_builder();
             $qb->add_constraint('gid', 'IN', $memberships);
             $qb->add_constraint('orgOpenpsaObtype', '>', org_openpsa_contacts_list_dba::MYCONTACTS);
             $organisations = $qb->execute();
             foreach ($organisations as $organisation) {
                 $contact->addChild('company', str_replace('&', '&amp;', ${$organisation}->get_label()));
             }
         }
         echo $simplexml->asXml();
     } else {
         midcom_show_style("show-mycontacts-header");
         foreach ($data['mycontacts'] as $person) {
             $data['person'] = $person;
             midcom_show_style("show-mycontacts-item");
         }
         midcom_show_style("show-mycontacts-footer");
     }
 }
Example #6
0
 /**
  * Iterate over all articles and create index record using the datamanager indexer
  * method.
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     if (is_null($config->get('symlink_topic')) && !$config->get('disable_indexing')) {
         $qb = midcom::get('dbfactory')->new_query_builder('midcom_db_article');
         $qb->add_constraint('topic', '=', $topic->id);
         $result = $qb->execute();
         if ($result) {
             $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb'));
             $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$datamanager) {
                 debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $config->get('schemadb'), MIDCOM_LOG_WARN);
                 continue;
             }
             foreach ($result as $article) {
                 if (!$datamanager->autoset_storage($article)) {
                     debug_add("Warning, failed to initialize datamanager for Article {$article->id}. Skipping it.", MIDCOM_LOG_WARN);
                     continue;
                 }
                 net_nehmer_blog_viewer::index($datamanager, $indexer, $topic);
             }
         }
     } elseif (is_null($config->get('symlink_topic')) && !$config->get('disable_search')) {
         debug_add("The topic {$topic->id} is is not to be indexed, skipping indexing.");
     } else {
         debug_add("The topic {$topic->id} is symlinked to another topic, skipping indexing.");
     }
     return true;
 }
Example #7
0
 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;
     }
 }
Example #8
0
 /**
  * Initialization of the handler class
  */
 public function _on_initialize()
 {
     org_openpsa_widgets_calendar::add_head_elements();
     // Load schema database
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
     $this->_root_event = org_openpsa_calendar_interface::find_root_event();
 }
Example #9
0
 /**
  * Prepare the indexer client
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     $qb = org_openpsa_invoices_invoice_dba::new_query_builder();
     $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb'));
     $indexer = new org_openpsa_invoices_midcom_indexer($topic, $indexer);
     $indexer->add_query('invoices', $qb, $schemadb);
     return $indexer;
 }
Example #10
0
 public function load_schemadb()
 {
     $schemadb = midcom_helper_datamanager2_schema::load_database($GLOBALS['midcom_config']['metadata_schema']);
     if ($this->_config->get('enable_review_dates') && !isset($schemadb['metadata']->fields['review_date'])) {
         $schemadb['metadata']->append_field('review_date', array('title' => $this->_l10n->get('review date'), 'type' => 'date', 'type_config' => array('storage_type' => 'UNIXTIME'), 'storage' => array('location' => 'parameter', 'domain' => 'midcom.helper.metadata', 'name' => 'review_date'), 'widget' => 'jsdate'));
     }
     return $schemadb;
 }
Example #11
0
 /**
  * Load the schmadb used in forms
  */
 public function _load_schemadb()
 {
     $this->_request_data['schemadb_suggestion'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_suggestion'));
     if (!$_MIDCOM->auth->user && $this->_config->get('use_captcha')) {
         $this->_request_data['schemadb_suggestion']['default']->append_field('captcha', array('title' => $this->_l10n_midcom->get('captcha field title'), 'storage' => null, 'type' => 'captcha', 'widget' => 'captcha', 'widget_config' => $this->_config->get('captcha_config')));
     }
     $this->_schemadb =& $this->_request_data['schemadb_suggestion'];
 }
Example #12
0
 private function _load_controller()
 {
     $this->_request_data['schemadb_salesproject'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_salesproject'));
     $this->_request_data['schemadb_salesproject_deliverable'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_deliverable'));
     $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('ajax');
     $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb_salesproject'];
     $this->_request_data['controller']->set_storage($this->_salesproject);
     $this->_request_data['controller']->process_ajax();
 }
Example #13
0
 private function _initialize_datamanager($schemadb_snippet)
 {
     // Initialize the datamanager with the schema
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($schemadb_snippet);
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->_schemadb);
     if (!$this->_datamanager) {
         throw new midcom_error("Datamanager could not be instantiated.");
     }
 }
Example #14
0
 function _load_schemadb($handler_id, &$args, &$data)
 {
     //We need the constants...
     midcom::get('componentloader')->load('org.openpsa.projects');
     if (isset($_GET['filename']) && is_string($_GET['filename']) && strpos($_GET['filename'], '.csv')) {
         $data['filename'] = $_GET['filename'];
     }
     return midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_hours'));
 }
Example #15
0
 public function __construct($schemadb = null)
 {
     parent::__construct();
     if (null === $schemadb) {
         $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_formmailer'));
     } else {
         $this->_schemadb = $schemadb;
     }
 }
Example #16
0
 function _load_schemadb($handler_id, &$args, &$data)
 {
     if (isset($args[0])) {
         $data['schemadb_to_use'] = 'schemadb_csvexport_' . $args[0];
     }
     if (isset($_GET['filename']) && is_string($_GET['filename']) && strpos($_GET['filename'], '.csv')) {
         $data['filename'] = $_GET['filename'];
     }
     return midcom_helper_datamanager2_schema::load_database($this->_config->get($data['schemadb_to_use']));
 }
Example #17
0
 public function load_schemadb()
 {
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_deliverable'));
     if ($this->get_schema_name() == 'subscription') {
         $schemadb['subscription']->fields['start']['type_config']['min_date'] = strftime('%Y-%m-%d');
     } else {
         $schemadb['default']->fields['end']['type_config']['min_date'] = strftime('%Y-%m-%d');
     }
     return $schemadb;
 }
Example #18
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_frontpage($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     if (midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_directmarketing_campaign_dba')) {
         $schemadb_campaign = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_campaign'));
         foreach (array_keys($schemadb_campaign) as $name) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "campaign/create/{$name}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($schemadb_campaign[$name]->description)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people.png', MIDCOM_TOOLBAR_ACCESSKEY => 'n'));
         }
     }
 }
Example #19
0
 /**
  * Load the schmadb used in forms
  */
 public function _load_schemadb()
 {
     $this->_request_data['schemadb'] = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_info'));
     $this->_schemadb =& $this->_request_data['schemadb'];
     if (!array_key_exists($this->_request_data['type'], $this->_schemadb)) {
         debug_push_class(__CLASS__, __FUNCTION__);
         debug_pop();
         $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, 'Failed to read info object (handler: ' . $handler_id . ')');
         //this will result in HTTP error 404
     }
 }
Example #20
0
 /**
  * Loads and prepares the schema database.
  *
  * The operations are done on all available schemas within the DB.
  */
 private function _load_schemadb()
 {
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     $operations = array();
     $operations['save'] = '';
     $operations['preview'] = $this->_l10n->get('preview');
     $operations['cancel'] = '';
     foreach ($this->_schemadb as $name => $schema) {
         $this->_schemadb[$name]->operations = $operations;
     }
 }
Example #21
0
 /**
  * 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.");
     }
 }
Example #22
0
 /**
  * Populates the node toolbar depending on the user's rights.
  */
 private function _populate_view_toolbar($task)
 {
     midcom::get('componentloader')->load('org.openpsa.projects');
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_hours'));
     foreach (array_keys($schemadb) as $name) {
         $create_url = "hours/create/{$name}/";
         if ($task) {
             $create_url .= $task . "/";
         }
         $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $create_url, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($schemadb[$name]->description)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new-event.png'));
     }
 }
Example #23
0
 public function test_autoset_storage()
 {
     $filename = 'file:/../test/midcom/helper/datamanager2/__files/schemadb_invoice.inc';
     $schemadb = midcom_helper_datamanager2_schema::load_database($filename);
     $dm = new midcom_helper_datamanager2_datamanager($schemadb);
     $invoice = $this->create_object('org_openpsa_invoices_invoice_dba');
     $this->assertTrue($dm->autoset_storage($invoice));
     $this->assertEquals('default', $dm->schema_name);
     $this->assertTrue(is_a($dm->storage, 'midcom_helper_datamanager2_storage_midgard'));
     $this->assertTrue($dm->autoset_storage($dm->storage));
     $this->assertEquals('default', $dm->schema_name);
 }
Example #24
0
 /**
  * Prepares the component's indexer client
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     $qb_organisations = org_openpsa_contacts_group_dba::new_query_builder();
     $qb_organisations->add_constraint('orgOpenpsaObtype', '<>', org_openpsa_contacts_group_dba::MYCONTACTS);
     $organisation_schema = midcom_helper_datamanager2_schema::load_database($config->get('schemadb_group'));
     $qb_persons = org_openpsa_contacts_person_dba::new_query_builder();
     $person_schema = midcom_helper_datamanager2_schema::load_database($config->get('schemadb_person'));
     $indexer = new org_openpsa_contacts_midcom_indexer($topic, $indexer);
     $indexer->add_query('organisations', $qb_organisations, $organisation_schema);
     $indexer->add_query('persons', $qb_persons, $person_schema);
     return $indexer;
 }
Example #25
0
 /**
  * Loads the schemadb (unless it has already been loaded).
  */
 function _load_schemadb()
 {
     if (!$this->_schemadb) {
         $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
         if ($this->_config->get('use_captcha') || !midcom::get('auth')->user && $this->_config->get('use_captcha_if_anonymous')) {
             $this->_schemadb['comment']->append_field('captcha', array('title' => $this->_l10n_midcom->get('captcha field title'), 'storage' => null, 'type' => 'captcha', 'widget' => 'captcha', 'widget_config' => $this->_config->get('captcha_config')));
         }
         if ($this->_config->get('ratings_enable') && array_key_exists('rating', $this->_schemadb['comment']->fields)) {
             $this->_schemadb['comment']->fields['rating']['hidden'] = false;
         }
     }
 }
Example #26
0
 public function _load_schemadb()
 {
     $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     if ($this->_mode == 'create' && count($this->_master->_handler['args']) == 1) {
         // We're creating invoice for chosen customer
         try {
             $this->_request_data['customer'] = new org_openpsa_contacts_group_dba($this->_master->_handler['args'][0]);
         } catch (midcom_error $e) {
             $this->_request_data['customer'] = new org_openpsa_contacts_person_dba($this->_master->_handler['args'][0]);
         }
     }
     $this->_modify_schema();
 }
Example #27
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_pdf($handler_id, array $args, array &$data)
 {
     $this->_invoice = new org_openpsa_invoices_invoice_dba($args[0]);
     $this->_request_data['invoice_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "invoice/" . $this->_invoice->guid . "/";
     //check for manually uploaded pdf-file & if user wants to replace it
     if (array_key_exists('cancel', $_POST)) {
         return new midcom_response_relocate($this->_request_data['invoice_url']);
     } else {
         if (array_key_exists('save', $_POST)) {
             $this->_update_attachment = true;
         } else {
             $data['confirmation_message'] = 'current pdf file was manually uploaded shall it be replaced ?';
             // load schema & datamanager to get attachment
             $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
             $this->_datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$this->_datamanager->autoset_storage($this->_invoice)) {
                 throw new midcom_error("Failed to create a DM2 instance for object {$this->_invoice->guid}.");
             }
             if ($this->_invoice->sent) {
                 $data['confirmation_message'] = 'invoice has already been sent. should it be replaced?';
             } else {
                 if (!empty($this->_datamanager->types['pdf_file']->attachments)) {
                     foreach ($this->_datamanager->types['pdf_file']->attachments as $attachment) {
                         $checksum = $attachment->get_parameter('org.openpsa.invoices', 'auto_generated');
                         // check if auto generated parameter is same as md5 in current-file
                         // if not the file was manually uploaded
                         if ($checksum) {
                             $blob = new midgard_blob($attachment->__object);
                             // check if md5 sum equals the one saved in auto_generated
                             if ($checksum == md5_file($blob->get_path())) {
                                 $this->_update_attachment = true;
                             }
                         }
                     }
                 } else {
                     $this->_update_attachment = true;
                 }
             }
         }
     }
     if ($this->_update_attachment) {
         $this->_request_data['billing_data'] = $this->_invoice->get_billing_data();
         if (self::render_and_attach_pdf($this->_invoice)) {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf created'));
         } else {
             midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('pdf creation failed') . ': ' . midcom_connection::get_error_string(), 'error');
         }
         return new midcom_response_relocate($this->_request_data["invoice_url"]);
     }
 }
Example #28
0
 public function test_on_update_object()
 {
     $filename = 'file:/../test/midcom/helper/datamanager2/__files/schemadb_invoice.inc';
     $schemadb = midcom_helper_datamanager2_schema::load_database($filename);
     $invoice = $this->create_object('org_openpsa_invoices_invoice_dba');
     $storage = new midcom_helper_datamanager2_storage_midgard($schemadb['default'], $invoice);
     $storage->_on_store_data('description', 'TEST');
     midcom::get('auth')->request_sudo('midcom.helper.datamanager2');
     $this->assertTrue($storage->_on_update_object(), midcom_connection::get_error_string());
     $invoice->refresh();
     midcom::get('auth')->drop_sudo();
     $this->assertEquals('TEST', $storage->object->description);
     $this->assertEquals('TEST', $invoice->description);
 }
Example #29
0
 /**
  * Loads and prepares the schema database.
  */
 public function load_schemadb()
 {
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_group'));
     $qb = midcom_db_member::new_query_builder();
     $qb->add_constraint('gid', '=', $this->_group->id);
     if ($qb->count_unchecked() > $this->_config->get('list_users_max') && isset($schemadb['default']->fields['persons'])) {
         unset($schemadb['default']->fields['persons']);
         $field_order_key = array_search('persons', $schemadb['default']->field_order);
         if ($field_order_key !== false) {
             unset($schemadb['default']->field_order[$field_order_key]);
         }
     }
     unset($qb);
     return $schemadb;
 }
Example #30
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_all($handler_id, array $args, array &$data)
 {
     $this->_request_data['campaign'] = new org_openpsa_directmarketing_campaign_dba($args[0]);
     $this->_prepare_toolbar();
     // List members who have been interviewed
     $qb = org_openpsa_directmarketing_campaign_member_dba::new_query_builder();
     $qb->add_constraint('campaign', '=', $this->_request_data['campaign']->id);
     $qb->begin_group("OR");
     $qb->add_constraint('orgOpenpsaObtype', '=', org_openpsa_directmarketing_campaign_member_dba::INTERVIEWED);
     $qb->add_constraint('orgOpenpsaObtype', '=', org_openpsa_directmarketing_campaign_member_dba::UNSUBSCRIBED);
     $qb->end_group();
     $this->_request_data['members_interviewed'] = $qb->execute();
     $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb'));
     $this->_request_data['datamanager'] = new midcom_helper_datamanager2_datamanager($schemadb);
 }