当前位置: 首页>>代码示例>>PHP>>正文


PHP midcom_connection类代码示例

本文整理汇总了PHP中midcom_connection的典型用法代码示例。如果您正苦于以下问题:PHP midcom_connection类的具体用法?PHP midcom_connection怎么用?PHP midcom_connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了midcom_connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_image

 public function generate_image($type, $filter_chain)
 {
     try {
         $original = new midcom_db_attachment($this->attachment);
     } catch (midcom_error $e) {
         $e->log();
         return false;
     }
     $found_derived = false;
     try {
         $derived = new midcom_db_attachment($this->{$type});
         $found_derived = true;
     } catch (midcom_error $e) {
         $derived = new midcom_db_attachment();
         $derived->parentguid = $original->parentguid;
         $derived->title = $original->title;
         $derived->mimetype = $original->mimetype;
         $derived->name = $type . '_' . $original->name;
     }
     $imagefilter = new midcom_helper_imagefilter($original);
     if (!$imagefilter->process_chain($filter_chain)) {
         throw new midcom_error('Image processing failed');
     }
     if (!$found_derived) {
         if (!$derived->create()) {
             throw new midcom_error('Failed to create derived image: ' . midcom_connection::get_error_string());
         }
         $this->{$type} = $derived->id;
         $this->update();
     }
     return $imagefilter->write($derived);
 }
开发者ID:nemein,项目名称:openpsa,代码行数:32,代码来源:image.php

示例2: testCRUD

 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.projects');
     $task = new org_openpsa_projects_task_dba();
     if (extension_loaded('midgard2')) {
         $stat = $task->create();
         $this->assertFalse($stat);
     }
     $project = $this->create_object('org_openpsa_projects_project');
     $task->project = $project->id;
     $stat = $task->create();
     $this->assertTrue($stat, midcom_connection::get_error_string());
     $this->register_object($task);
     $this->assertEquals(ORG_OPENPSA_OBTYPE_TASK, $task->orgOpenpsaObtype);
     $task->refresh();
     $this->assertEquals('Task #' . $task->id, $task->title);
     $this->assertEquals(org_openpsa_projects_task_status_dba::PROPOSED, $task->status);
     $task->title = 'Test Task';
     $stat = $task->update();
     $this->assertTrue($stat);
     $this->assertEquals('Test Task', $task->title);
     $stat = $task->delete();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:25,代码来源:taskTest.php

示例3: _handler_delete

 /**
  * @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)
 {
     midcom::get('auth')->require_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface');
     $this->_group = new midcom_db_group($args[0]);
     if (array_key_exists('org_openpsa_user_deleteok', $_POST)) {
         $delete_succeeded = $this->_group->delete();
         $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
         if ($delete_succeeded) {
             // Update the index
             $indexer = midcom::get('indexer');
             $indexer->delete($this->_group->guid);
             return new midcom_response_relocate('');
         } else {
             // Failure, give a message
             midcom::get('uimessages')->add($this->_l10n->get('org.openpsa.user'), $this->_l10n->get("failed to delete group, reason") . ' ' . midcom_connection::get_error_string(), 'error');
             return new midcom_response_relocate($prefix . 'group/' . $this->_group->guid . '/');
         }
     }
     $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_group);
     $data['group'] = $this->_group;
     org_openpsa_widgets_tree::add_head_elements();
     $this->add_breadcrumb('groups/', $this->_l10n->get('groups'));
     $this->add_breadcrumb('', sprintf($this->_l10n_midcom->get('delete %s'), $this->_group->get_label()));
     $this->bind_view_to_object($this->_group);
 }
开发者ID:nemein,项目名称:openpsa,代码行数:30,代码来源:delete.php

示例4: testCRUD

 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.invoices');
     $data = new org_openpsa_invoices_billing_data_dba();
     $data->linkGuid = self::$_contact->guid;
     $data->useContactAddress = true;
     $stat = $data->create();
     $this->assertTrue($stat, midcom_connection::get_error_string());
     $this->register_object($data);
     $parent = $data->get_parent();
     $this->assertEquals($parent->guid, self::$_contact->guid);
     self::$_contact->refresh();
     $this->assertEquals(self::$_contact->street, $data->street);
     $data->vat = 12;
     $data->due = 12;
     $stat = $data->update();
     $this->assertTrue($stat);
     self::$_contact->refresh();
     $invoice = new org_openpsa_invoices_invoice_dba();
     $invoice->customerContact = self::$_contact->id;
     $invoice_data = $invoice->get_billing_data();
     $this->assertEquals($data->guid, $invoice_data->guid);
     $this->assertEquals($data->vat, $invoice->get_default('vat'));
     $this->assertEquals($data->due, $invoice->get_default('due'));
     $stat = $data->delete();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:28,代码来源:dataTest.php

示例5: _on_creating

 /**
  * Don't save aerodrome if another aerodrome is in same place or exists with same ICAO
  */
 public function _on_creating()
 {
     if ($this->longitude && $this->latitude) {
         $qb = org_routamc_positioning_aerodrome_dba::new_query_builder();
         $qb->add_constraint('longitude', '=', $this->longitude);
         $qb->add_constraint('latitude', '=', $this->latitude);
         $qb->set_limit(1);
         $matches = $qb->execute_unchecked();
         if (count($matches) > 0) {
             // We don't need to save duplicate entries
             return false;
         }
     }
     if (!empty($this->icao)) {
         $qb = org_routamc_positioning_aerodrome_dba::new_query_builder();
         $qb->add_constraint('icao', '=', $this->icao);
         $qb->set_limit(1);
         $matches = $qb->execute_unchecked();
         if (count($matches) > 0) {
             // We don't need to save duplicate entries
             midcom_connection::set_error(MGD_ERR_DUPLICATE);
             return false;
         }
     }
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:29,代码来源:aerodrome.php

示例6: _handler_csv

 public function _handler_csv($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_valid_user();
     midcom::get()->disable_limits();
     $this->_load_datamanager($this->_load_schemadb($handler_id, $args, $data));
     $this->_objects = $this->_load_data($handler_id, $args, $data);
     if (!isset($args[0]) || empty($args[0])) {
         //We do not have filename in URL, generate one and redirect
         $fname = preg_replace('/[^a-z0-9-]/i', '_', strtolower($this->_topic->extra)) . '_' . date('Y-m-d') . '.csv';
         if (strpos(midcom_connection::get_url('uri'), '/', strlen(midcom_connection::get_url('uri')) - 2)) {
             return new midcom_response_relocate(midcom_connection::get_url('uri') . $fname);
         } else {
             return new midcom_response_relocate(midcom_connection::get_url('uri') . "/{$fname}");
         }
     }
     if (!isset($data['filename']) || $data['filename'] == '') {
         $data['filename'] = str_replace('.csv', '', $args[0]);
     }
     $this->_init_csv_variables();
     midcom::get()->skip_page_style = true;
     // FIXME: Use global configuration
     //midcom::get('cache')->content->content_type($this->_config->get('csv_export_content_type'));
     midcom::get('cache')->content->content_type('application/csv');
     _midcom_header('Content-Disposition: filename=' . $data['filename']);
 }
开发者ID:nemein,项目名称:openpsa,代码行数:25,代码来源:dataexport.php

示例7: _on_execute

 /**
  * Find hanging duplicate marks (that no longer point anywhere) and clear them
  */
 public function _on_execute()
 {
     debug_add('_on_execute called');
     if (!$this->_config->get('enable_duplicate_search')) {
         debug_add('Duplicate operations disabled, aborting', MIDCOM_LOG_INFO);
         return;
     }
     // Untill the FIXME below is handled we abort
     debug_add('Duplicate cleanup disabled since it needs code cleanup for 1.8 Midgfard, aborting', MIDCOM_LOG_ERROR);
     return;
     ignore_user_abort();
     $qb = new midgard_query_builder('midgard_parameter');
     $qb->add_constraint('domain', '=', 'org.openpsa.contacts.duplicates:possible_duplicate');
     $qb->add_order('name', 'ASC');
     $results = @$qb->execute();
     foreach ($results as $param) {
         try {
             $obj = midcom::get('dbfactory')->get_object_by_guid($param->name);
         } catch (midcom_error $e) {
             debug_add("GUID {$param->name} points to nonexistent person, removing possible duplicate mark", MIDCOM_LOG_INFO);
             if (!$param->delete()) {
                 debug_add("Failed to delete parameter {$param->guid}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
             }
         }
     }
     debug_add('Done');
     return;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:31,代码来源:clean.php

示例8: _on_execute

 /**
  * Find all old send tokens and clear them.
  */
 public function _on_execute()
 {
     //Disable limits, TODO: think if this could be done in smaller chunks to save memory.
     midcom::get()->disable_limits();
     debug_add('_on_execute called');
     $days = $this->_config->get('send_token_max_age');
     if ($days == 0) {
         debug_add('send_token_max_age evaluates to zero, aborting');
         return;
     }
     $th = time() - $days * 3600 * 24;
     $qb = org_openpsa_directmarketing_campaign_messagereceipt_dba::new_query_builder();
     $qb->add_constraint('token', '<>', '');
     $qb->add_constraint('timestamp', '<', $th);
     $qb->add_constraint('orgOpenpsaObtype', '=', org_openpsa_directmarketing_campaign_messagereceipt_dba::SENT);
     $ret = $qb->execute_unchecked();
     if ($ret === false || !is_array($ret)) {
         //TODO: display some error ?
         return false;
     }
     if (empty($ret)) {
         debug_add('No results, returning early.');
         return;
     }
     foreach ($ret as $receipt) {
         debug_add("clearing token '{$receipt->token}' from receipt #{$receipt->id}");
         $receipt->token = '';
         $stat = $receipt->update();
         if (!$stat) {
             debug_add("FAILED to update receipt #{$receipt->id}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_WARN);
         }
     }
     debug_add('Done');
     return;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:38,代码来源:cleartokens.php

示例9: _handler_trash

 /**
  * Trash 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_trash($handler_id, array $args, array &$data)
 {
     midcom::get('auth')->require_admin_user();
     midcom::get('cache')->content->no_cache();
     $data['view_title'] = $this->_l10n->get('trash');
     midcom::get('head')->set_pagetitle($data['view_title']);
     $data['types'] = array();
     foreach (midcom_connection::get_schema_types() as $type) {
         if (substr($type, 0, 2) == '__') {
             continue;
         }
         if (class_exists('midgard_reflector_object')) {
             // In Midgard2 we can have objects that don't
             // have metadata. These should not be shown
             // in trash.
             $ref = new midgard_reflector_object($type);
             if (!$ref->has_metadata_class($type)) {
                 debug_add("{$type} has no metadata, skipping", MIDCOM_LOG_DEBUG);
                 continue;
             }
         }
         $qb = new midgard_query_builder($type);
         $qb->include_deleted();
         $qb->add_constraint('metadata.deleted', '=', true);
         $data['types'][$type] = $qb->count();
     }
     // Set the breadcrumb data
     $this->add_breadcrumb('__mfa/asgard/', $this->_l10n->get('midgard.admin.asgard'));
     $this->add_breadcrumb('__mfa/asgard/trash/', $this->_l10n->get('trash'));
 }
开发者ID:nemein,项目名称:openpsa,代码行数:38,代码来源:undelete.php

示例10: _on_execute

 /**
  * Find all old temporary reports and clear them.
  */
 public function _on_execute()
 {
     //Disable limits, TODO: think if this could be done in smaller chunks to save memory.
     midcom::get()->disable_limits();
     debug_add('_on_execute called');
     $days = $this->_config->get('temporary_report_max_age');
     if ($days == 0) {
         debug_add('temporary_report_max_age evaluates to zero, aborting');
         return;
     }
     $th = time() - $days * 3600 * 24;
     $qb = org_openpsa_reports_query_dba::new_query_builder();
     $qb->add_constraint('metadata.created', '<', $th);
     $qb->add_constraint('orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_REPORT_TEMPORARY);
     $ret = $qb->execute_unchecked();
     if ($ret === false || !is_array($ret)) {
         //TODO: display some error ?
         return false;
     }
     if (empty($ret)) {
         debug_add('No results, returning early.');
         return;
     }
     foreach ($ret as $query) {
         debug_add("removing temporary query #{$query->id}");
         $stat = $query->delete();
         if (!$stat) {
             debug_add("FAILED to delete query #{$query->id}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_WARN);
         }
     }
     debug_add('Done');
     return;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:36,代码来源:clearold.php

示例11: _on_execute

 /**
  * Find all old temporary reports and clear them.
  */
 public function _on_execute()
 {
     debug_add('_on_execute called');
     midcom::get('auth')->request_sudo('net.nemein.tag');
     $qb_tags = net_nemein_tag_tag_dba::new_query_builder();
     $tags = $qb_tags->execute_unchecked();
     if (!is_array($tags)) {
         // QB error
         midcom::get('auth')->drop_sudo();
         return;
     }
     foreach ($tags as $tag) {
         debug_add("Processing tag #{$tag->id} ('{$tag->tag}')");
         $qb_links = net_nemein_tag_link_dba::new_query_builder();
         $qb_links->add_constraint('tag', '=', $tag->id);
         $count = $qb_links->count_unchecked();
         if ($count === false) {
             // QB error, skip
             debug_add("There was QB level error, skip rest of the checks");
             continue;
         }
         if ($count > 0) {
             // Tag has links, skip
             debug_add("Tag has links to it, do not clean");
             continue;
         }
         debug_add("Cleaning dangling tag #{$tag->id} ('{$tag->tag}')", MIDCOM_LOG_INFO);
         if (!$tag->delete()) {
             debug_add("Could not delete dangling tag #{$tag->id} ('{$tag->tag}'), errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         }
     }
     debug_add('done');
     midcom::get('auth')->drop_sudo();
     return;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:38,代码来源:clean.php

示例12: _handler_edit

 /**
  * Handle the request for editing contact list
  *
  * @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)
 {
     midcom::get('auth')->require_valid_user();
     // Get the current user
     $this->_person = new midcom_db_person(midcom_connection::get_user());
     $this->_person->require_do('midgard:update');
     // Load the controller
     $data['controller'] = $this->get_controller('simple', $this->_person);
     // Process the form
     switch ($data['controller']->process_form()) {
         case 'save':
         case 'cancel':
             if (isset($_GET['org_openpsa_calendar_returnurl'])) {
                 $url = $_GET['org_openpsa_calendar_returnurl'];
             } else {
                 $url = '';
             }
             return new midcom_response_relocate($url);
     }
     // Add the breadcrumb pieces
     if (isset($_GET['org_openpsa_calendar_returnurl'])) {
         $this->add_breadcrumb($_GET['org_openpsa_calendar_returnurl'], $this->_l10n->get('calendar'));
     }
     $this->add_breadcrumb('filters/', $this->_l10n->get('choose calendars'));
 }
开发者ID:nemein,项目名称:openpsa,代码行数:32,代码来源:filters.php

示例13: run

 public function run($object)
 {
     if (!$object->delete()) {
         throw new \midcom_error("failed to delete " . get_class($object) . " #" . $object->id . ': ' . \midcom_connection::get_error_string());
     }
     return array();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:7,代码来源:delete.php

示例14: testCRUD

 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.sales');
     $deliverable = new org_openpsa_sales_salesproject_deliverable_dba();
     $deliverable->salesproject = $this->_salesproject->id;
     $deliverable->plannedUnits = 2.5;
     $deliverable->pricePerUnit = 100;
     $stat = $deliverable->create();
     $this->assertTrue($stat, midcom_connection::get_error_string());
     $this->register_object($deliverable);
     $this->assertEquals($deliverable->price, 250);
     $parent = $deliverable->get_parent();
     $this->assertEquals($parent->guid, $this->_salesproject->guid);
     $this->_salesproject->refresh();
     $this->assertEquals($this->_salesproject->value, 250);
     $this->assertEquals($this->_salesproject->profit, 250);
     $deliverable->plannedUnits = 2;
     $stat = $deliverable->update();
     $this->assertTrue($stat);
     $this->_salesproject->refresh();
     $this->assertEquals($this->_salesproject->value, 200);
     $this->assertEquals($this->_salesproject->profit, 200);
     $stat = $deliverable->delete();
     $this->assertTrue($stat);
     $this->_salesproject->calculate_price();
     $this->assertEquals($this->_salesproject->value, 0);
     $this->assertEquals($this->_salesproject->profit, 0);
     midcom::get('auth')->drop_sudo();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:29,代码来源:deliverableTest.php

示例15: _on_execute

 /**
  * Loads all entries that need to be processed and processes them.
  */
 public function _on_execute()
 {
     $qb = midcom_services_at_entry_dba::new_query_builder();
     // (to be) start(ed) AND last touched over two days ago
     $qb->add_constraint('start', '<=', time() - 3600 * 24 * 2);
     $qb->begin_group('OR');
     $qb->add_constraint('host', '=', midcom_connection::get('host'));
     $qb->add_constraint('host', '=', 0);
     $qb->end_group();
     $qb->add_constraint('metadata.revised', '<=', date('Y-m-d H:i:s', time() - 3600 * 24 * 2));
     $qb->add_constraint('status', '>=', midcom_services_at_entry_dba::RUNNING);
     midcom::get('auth')->request_sudo('midcom.services.at');
     $qbret = $qb->execute();
     if (empty($qbret)) {
         debug_add('Got empty resultset, exiting');
         midcom::get('auth')->drop_sudo();
         return;
     }
     foreach ($qbret as $entry) {
         debug_add("Deleting dangling entry #{$entry->id}\n", MIDCOM_LOG_INFO);
         debug_print_r("Entry #{$entry->id} dump: ", $entry);
         $entry->delete();
     }
     midcom::get('auth')->drop_sudo();
 }
开发者ID:nemein,项目名称:openpsa,代码行数:28,代码来源:clean.php


注:本文中的midcom_connection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。