本文整理汇总了PHP中midcom_connection::get_error_string方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_connection::get_error_string方法的具体用法?PHP midcom_connection::get_error_string怎么用?PHP midcom_connection::get_error_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midcom_connection
的用法示例。
在下文中一共展示了midcom_connection::get_error_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: _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);
}
示例3: _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;
}
示例4: _handle_ajax
/**
* Handle the AJAX request
*
* @todo This function is unused
*/
public function _handle_ajax()
{
$update_succeeded = false;
$errstr = null;
$user = new midcom_db_person($this->_request_data['user']->id);
if (array_key_exists('org_openpsa_calendar_filters_add', $_POST)) {
try {
$target = new midcom_db_person($_POST['org_openpsa_calendar_filters_add']);
$update_succeeded = $user->parameter('org_openpsa_calendar_show', $_POST['org_openpsa_calendar_filters_add'], 1);
} catch (midcom_error $e) {
$e->log();
}
} else {
if (array_key_exists('org_openpsa_calendar_filters_remove', $_POST)) {
try {
$target = new midcom_db_person($_POST['org_openpsa_calendar_filters_remove']);
$update_succeeded = $user->parameter('org_openpsa_calendar_show', $_POST['org_openpsa_calendar_filters_remove'], '');
} catch (midcom_error $e) {
$e->log();
}
}
}
$errstr = midcom_connection::get_error_string();
$response = new midcom_response_xml();
$response->result = $update_succeeded;
$response->status = $errstr;
$response->send();
//This will exit.
}
示例5: 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();
}
示例6: 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();
}
示例7: _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;
}
示例8: 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);
}
示例9: 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();
}
示例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;
}
示例11: _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;
}
示例12: obj_cleanup
function obj_cleanup(&$object)
{
if ($object->delete()) {
$object->purge();
return true;
}
echo "Deletion failed for {$object->guid}, errstr: " . midcom_connection::get_error_string() . "<br>\n";
}
示例13: test_copy_from_file
public function test_copy_from_file()
{
$attachment = $this->create_object('midcom_db_attachment', array('parentguid' => self::$_topic->guid));
$stat = $attachment->copy_from_file(self::$_filepath . 'attach.png');
$this->assertTrue($stat, midcom_connection::get_error_string());
$blob = new midgard_blob($attachment->__object);
$this->assertFileEquals(self::$_filepath . 'attach.png', $blob->get_path());
}
示例14: net_nemein_redirector_tinyurl_dba
/**
* DM2 creation callback, binds to the current content topic.
*/
public function &dm2_create_callback(&$controller)
{
$this->_tinyurl = new net_nemein_redirector_tinyurl_dba();
$this->_tinyurl->node = $this->_topic->guid;
if (!$this->_tinyurl->create()) {
throw new midcom_error('Failed to create a new TinyURL object. Last Midgard error was: ' . midcom_connection::get_error_string());
}
return $this->_tinyurl;
}
示例15: org_openpsa_products_product_group_dba
/**
* DM2 creation callback, binds to the current content topic.
*/
public function &dm2_create_callback(&$controller)
{
$this->_group = new org_openpsa_products_product_group_dba();
$this->_group->up = $this->_request_data['up'];
if (!$this->_group->create()) {
debug_print_r('We operated on this object:', $this->_group);
throw new midcom_error('Failed to create a new product group. Last Midgard error was: ' . midcom_connection::get_error_string());
}
return $this->_group;
}