mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-30 09:48:38 +01:00
* Infolog - Fix project got lost on reload if set via link
This commit is contained in:
parent
80576f7956
commit
45f14145a1
@ -479,6 +479,8 @@ class infolog_bo
|
|||||||
$info['info_link_id'] = 0; // link might have been deleted
|
$info['info_link_id'] = 0; // link might have been deleted
|
||||||
$info['info_custom_from'] = (int)!!$info['info_from'];
|
$info['info_custom_from'] = (int)!!$info['info_from'];
|
||||||
|
|
||||||
|
$this->get_pm_id($info);
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,10 +1167,11 @@ class infolog_bo
|
|||||||
}
|
}
|
||||||
Link::unlink($old_link_id);
|
Link::unlink($old_link_id);
|
||||||
}
|
}
|
||||||
// if added link is a project and no other project selected, also add as project
|
// if linked to a project and no other project selected, also add as project
|
||||||
if ($app == 'projectmanager' && $id && !$values['pm_id'])
|
$links = Link::get_links('infolog', $values['info_id'], 'projectmanager');
|
||||||
|
if (!$values['pm_id'] && count($links))
|
||||||
{
|
{
|
||||||
$values['old_pm_id'] = $values['pm_id'] = $id;
|
$values['old_pm_id'] = $values['pm_id'] = array_pop($links);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ namespace EGroupware\Infolog;
|
|||||||
require_once realpath(__DIR__.'/../../api/tests/AppTest.php'); // Application test base
|
require_once realpath(__DIR__.'/../../api/tests/AppTest.php'); // Application test base
|
||||||
|
|
||||||
use Egroupware\Api;
|
use Egroupware\Api;
|
||||||
|
use Egroupware\Api\Link;
|
||||||
use Egroupware\Api\Etemplate;
|
use Egroupware\Api\Etemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,6 +151,55 @@ class SetProjectManagerTest extends \EGroupware\Api\AppTest
|
|||||||
$this->checkElements();
|
$this->checkElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a project by only adding it as a link. First linked project gets
|
||||||
|
* taken as _the_ project.
|
||||||
|
*/
|
||||||
|
public function testAddProjectViaLink()
|
||||||
|
{
|
||||||
|
// Saving the infolog should try to send a notification
|
||||||
|
$this->bo->tracking->expects($this->exactly(2))
|
||||||
|
->method('track')
|
||||||
|
->withConsecutive(
|
||||||
|
// First call - creation
|
||||||
|
[$this->callback(function($subject) { return is_null($subject['pm_status']);})],
|
||||||
|
// Second call - after setting project
|
||||||
|
[$this->callback(function($subject) { return $subject['pm_id'] == $this->pm_id;})]
|
||||||
|
);
|
||||||
|
|
||||||
|
$info = $this->getTestInfolog();
|
||||||
|
|
||||||
|
$this->info_id = $this->bo->write($info);
|
||||||
|
$this->assertInternalType('integer', $this->info_id);
|
||||||
|
$this->assertGreaterThan(0, $this->info_id);
|
||||||
|
|
||||||
|
// Force links to run notification now so we get valid testing - it
|
||||||
|
// usually waits until Egw::on_shutdown();
|
||||||
|
Api\Link::run_notifies();
|
||||||
|
|
||||||
|
// Now load it again
|
||||||
|
$info = $this->bo->read($this->info_id);
|
||||||
|
|
||||||
|
// Set project by link
|
||||||
|
Link::link('infolog', $this->info_id, 'projectmanager', $this->pm_id);
|
||||||
|
Api\Link::run_notifies();
|
||||||
|
|
||||||
|
$this->bo->write($info);
|
||||||
|
|
||||||
|
// Now load it again
|
||||||
|
$info = $this->bo->read($this->info_id);
|
||||||
|
|
||||||
|
// Check pm_id is there
|
||||||
|
$this->assertNotNull($info['pm_id'], 'Project was not set');
|
||||||
|
|
||||||
|
// Force links to run notification now so we get valid testing - it
|
||||||
|
// usually waits until Egw::on_shutdown();
|
||||||
|
Api\Link::run_notifies();
|
||||||
|
|
||||||
|
// Check project
|
||||||
|
$this->checkElements();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new infolog entry, set project via info_contact
|
* Create a new infolog entry, set project via info_contact
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user