Verified Commit 57116975 authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: feat(Tasks) - mail method more generic part 2

Making email retrieval more generic and static callable part 2
Showing with 10 additions and 9 deletions
+10 -9
...@@ -134,9 +134,15 @@ class tasksMail extends simplePlugin ...@@ -134,9 +134,15 @@ class tasksMail extends simplePlugin
// create a method which return the objectype and attribute names required // create a method which return the objectype and attribute names required
$mailObject = $this->getMailObject($mailAttr); $mailObject = $this->getMailObject($mailAttr);
// Get the members or groups selected
$attributeValue = $this->attributesAccess['fdTasksMailUsers']->getValue();
// Extract members from potential groups and dyn-groups.
$listOfDN = tasks::extractMembersFromGroups($attributeValue);
// send the objectype and attrs name to the below method // send the objectype and attrs name to the below method
$this->setEmailsFromSelectedDN($mailObject, $mailAttr); $this->attributesAccess['fdTasksEmailsFromDN']->setValue(
array_values($this->getEmailsFromSelectedDN($mailObject, $mailAttr, $listOfDN))
);
return TRUE; return TRUE;
} }
...@@ -163,19 +169,14 @@ class tasksMail extends simplePlugin ...@@ -163,19 +169,14 @@ class tasksMail extends simplePlugin
} }
/* /*
* Populate the fdTasksEmailsFromDN attribute with related mails addresses. * Retrieve registered emails for each DN passed.
*/ */
public function setEmailsFromSelectedDN ($mailObject, $mailAttr): void public static function getEmailsFromSelectedDN ($mailObject, $mailAttr, $listOfDN): array
{ {
global $config; global $config;
$ldap = $config->get_ldap_link(); $ldap = $config->get_ldap_link();
$mailList = []; $mailList = [];
// Get the members or groups selected
$attributeValue = $this->attributesAccess['fdTasksMailUsers']->getValue();
// Extract members from potential groups and dyn-groups.
$listOfDN = tasks::extractMembersFromGroups($attributeValue);
foreach ($listOfDN as $dn) { foreach ($listOfDN as $dn) {
// Position ldap to the dn required (limit search). // Position ldap to the dn required (limit search).
$ldap->cd($dn); $ldap->cd($dn);
...@@ -196,7 +197,7 @@ class tasksMail extends simplePlugin ...@@ -196,7 +197,7 @@ class tasksMail extends simplePlugin
// A possible enhancement is to recall itself with another mailObject / attr // A possible enhancement is to recall itself with another mailObject / attr
} }
} }
$this->attributesAccess['fdTasksEmailsFromDN']->setValue(array_values($mailList)); return $mailList;
} }
function save (): array function save (): array
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment