mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
* Infolog - Fix parent contact going missing when creating a sub entry
This commit is contained in:
parent
1848f6d35f
commit
590b23b2a8
@ -1054,7 +1054,7 @@ class infolog_bo
|
||||
// Update modified timestamp of parent
|
||||
if($values['info_id_parent'] && $touch_modified)
|
||||
{
|
||||
$parent = $this->read($values['info_id_parent'], false, 'server', true);
|
||||
$parent = $this->read($values['info_id_parent'], true, 'server', true);
|
||||
$this->write($parent, false, true, false, true, false, null, $ignore_acl);
|
||||
}
|
||||
}
|
||||
@ -1072,6 +1072,8 @@ class infolog_bo
|
||||
protected function write_check_links(&$values)
|
||||
{
|
||||
$old_link_id = (int)$values['info_link_id'];
|
||||
$from = $values['info_from'];
|
||||
|
||||
if($values['info_contact'] && !(
|
||||
is_array($values['info_contact']) && $values['info_contact']['id'] == 'none'
|
||||
) || (
|
||||
@ -1132,7 +1134,8 @@ class infolog_bo
|
||||
else
|
||||
{
|
||||
unset($values['info_link_id']);
|
||||
$values['info_from'] = null;
|
||||
unset($values['info_contact']);
|
||||
$values['info_from'] = $from ? $from : null;
|
||||
}
|
||||
if($values['info_id'] && $values['old_pm_id'] !== $values['pm_id'])
|
||||
{
|
||||
|
@ -207,7 +207,7 @@
|
||||
</box>
|
||||
<box id="enddate_popup" class="action_popup prompt">
|
||||
<vbox>
|
||||
<description value="End date" class="promptheader"/>
|
||||
<description value="Due date" class="promptheader"/>
|
||||
<description id="enddate_action[title]"/>
|
||||
<date-time id="enddate" class="action_popup-content"/>
|
||||
<hbox>
|
||||
|
@ -42,9 +42,11 @@ class ContactTest extends \EGroupware\Api\AppTest
|
||||
public function tearDown()
|
||||
{
|
||||
// Double delete to make sure it's gone, not preserved due to history setting
|
||||
$this->bo->delete($this->info_id);
|
||||
$this->bo->delete($this->info_id);
|
||||
|
||||
if($this->info_id)
|
||||
{
|
||||
$this->bo->delete($this->info_id);
|
||||
$this->bo->delete($this->info_id);
|
||||
}
|
||||
$this->bo = null;
|
||||
}
|
||||
|
||||
@ -153,6 +155,71 @@ class ContactTest extends \EGroupware\Api\AppTest
|
||||
// Make a call to edit, looks like initial load
|
||||
$_REQUEST['info_id'] = $this->info_id;
|
||||
$this->ui->edit();
|
||||
unset($_REQUEST['info_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that creating a sub-infolog keeps info_contact on the parent
|
||||
*
|
||||
* @ticket 24920
|
||||
*/
|
||||
public function testSubEntry()
|
||||
{
|
||||
// Parent needs a project & contact for this
|
||||
$content = array(
|
||||
'contact' => array(
|
||||
'app' => 'addressbook',
|
||||
'id' => Null,
|
||||
'search'=> 'Free text'
|
||||
)
|
||||
);
|
||||
$parent = $this->getTestInfolog($content);
|
||||
|
||||
// Skipping notifications - save initial state
|
||||
$parent_id = $this->bo->write($parent, true, true, true, true);
|
||||
|
||||
// Mock the etemplate call to check sub gets parent's contact
|
||||
$sub = array();
|
||||
$this->ui->tmpl->expects($this->once())
|
||||
->method('exec')
|
||||
->will(
|
||||
$this->returnCallback(function($method, $info) use($parent, &$sub) {
|
||||
$this->assertNull($info['info_id']);
|
||||
$this->assertEquals($parent['info_id'], $info['info_id_parent']);
|
||||
$this->assertEquals($parent['info_contact']['id'], $info['info_contact']['id']);
|
||||
$this->assertEquals($parent['info_contact']['app'], $info['info_contact']['app']);
|
||||
$this->assertEquals($parent['info_from'], $info['info_from']);
|
||||
$sub = $info;
|
||||
return true;
|
||||
})
|
||||
);
|
||||
|
||||
// Make a sub-entry
|
||||
$_REQUEST['action'] = 'sp';
|
||||
$_REQUEST['action_id'] = $parent['info_id'];
|
||||
$this->ui->edit();
|
||||
|
||||
// Skipping notifications - save initial state
|
||||
$this->info_id = $this->bo->write($sub, true, true, true, true);
|
||||
|
||||
// Read it back to check
|
||||
$saved = $this->bo->read($this->info_id);
|
||||
|
||||
$this->assertEquals($parent['pm_id'], $saved['pm_id']);
|
||||
$this->assertEquals($parent['info_from'], $saved['info_from']);
|
||||
$this->assertEquals(json_encode($parent['info_contact']), json_encode($saved['info_contact']));
|
||||
$this->assertEquals($parent_id, $saved['info_id_parent']);
|
||||
|
||||
// Check parent
|
||||
$parent_reload = $this->bo->read($parent_id);
|
||||
|
||||
$this->assertEquals($parent['pm_id'], $parent_reload['pm_id']);
|
||||
$this->assertEquals($parent['info_from'], $parent_reload['info_from']);
|
||||
$this->assertEquals($parent['info_contact'], $parent_reload['info_contact']);
|
||||
|
||||
// Remove parent (twice, for history preservation)
|
||||
$this->bo->delete($parent_id);
|
||||
$this->bo->delete($parent_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,7 +481,10 @@ class SetProjectManagerTest extends \EGroupware\Api\AppTest
|
||||
$info = $this->bo->read($this->info_id);
|
||||
|
||||
// Check contact was cleared
|
||||
$this->assertNull($info['info_contact'], 'Contact was not cleared');
|
||||
$this->assertTrue(is_null($info['info_contact']) || (
|
||||
$info['info_contact']['id'] == 'none' && !$info['info_contact']['search']),
|
||||
'Contact was not cleared'
|
||||
);
|
||||
|
||||
// Check pm_id is gone
|
||||
$this->assertNull($info['pm_id'], 'Project was not removed');
|
||||
|
Loading…
Reference in New Issue
Block a user