allow to fetch identity by assigned serverID (fetches the first match found)

This commit is contained in:
Klaus Leithoff 2011-07-19 08:27:34 +00:00
parent f3538e3f9a
commit 84b6a5d87c

View File

@ -30,10 +30,14 @@
// enable userdefined signatures
var $ea_user_defined_signatures = false;
function getIdentity($_id = -1)
function getIdentity($_id = -1, $_byProfileID=false)
{
if($_id != -1)
{
if ($_byProfileID===true)
{
foreach ((array)$this->identities as $id => $ident) if ($ident->id==$_id) return $ident;
}
return $this->identities[$_id];
}
else
@ -88,6 +92,7 @@
function setIdentity($_identityObject, $_id = -1)
{
//error_log(__METHOD__.__LINE__.' called with ID '.$_id.' ->'.array2string($_identityObject).function_backtrace());
if(is_a($_identityObject, 'ea_identity'))
{
if($_id != -1)
@ -95,9 +100,16 @@
$this->identities[$_id] = $_identityObject;
}
else
{
if ($_identityObject->id)
{
$this->identities[$_identityObject->id] = $_identityObject;
}
else
{
$this->identities[] = $_identityObject;
}
}
return true;
}