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

:sparkling: Feat(Tasks) - First steps towards mails retrieval.

Mail retrieval from DN put in LDAP.
Commit to fix in order to save attribute in ldap.
Showing with 48 additions and 3 deletions
+48 -3
......@@ -320,6 +320,11 @@ attributetype ( 1.3.6.1.4.1.38414.89.1.6 NAME 'fdTasksCreationDate'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
attributetype ( 1.3.6.1.4.1.38414.89.1.7 NAME 'fdTasksEmailsFromdDN'
DESC 'Fusion Directory - Emails derived from DN'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
##### Classes #####
objectclass ( 1.3.6.1.4.1.10098.1.2.1.19.4 NAME 'gosaDepartment' SUP top AUXILIARY
......@@ -413,4 +418,4 @@ objectclass (1.3.6.1.4.1.38414.89.2.2 NAME 'fdTasksMail'
DESC 'FusionDirectory - Tasks objects Mail'
SUP top AUXILIARY
MUST ( fdTasksMailObject )
MAY ( fdTasksMailUsers ) )
MAY ( fdTasksMailUsers $ fdTasksEmailsFromdDN ) )
......@@ -64,9 +64,15 @@ class tasksMail extends simplePlugin
'', _('Select Users/Groups'),
'fdTasksMailUsers', TRUE,
[], 'dn'
)
),
// new HiddenAttribute('fdTasksEmailsFromdDN', TRUE, '', '', 'E-Mails', 'Emails from DN'),
new StringAttribute(
_('Emails'), _('Name for this task'),
'fdTasksEmailsFromdDN', TRUE
),
]
],
],
];
}
......@@ -85,6 +91,40 @@ class tasksMail extends simplePlugin
}
asort($tmpSearch);
$this->attributesAccess['fdTasksMailObject']->setChoices(array_keys($tmpSearch), array_values($tmpSearch));
$this->attributesAccess['fdTasksEmailsFromdDN']->setVisible(FALSE);
}
/*
* Populate the fdTasksEmailsFromDN attribute with related mails addresses.
*/
protected function shouldSave (): bool
{
global $config;
$ldap = $config->get_ldap_link();
if ($this->attributesAccess['fdTasksMailUsers']->getValue() == TRUE ) {
foreach ($this->attributesAccess['fdTasksMailUsers']->getValue() as $dn) {
$ldap->cd($dn);
$filter = "(objectClass=gosaMailAccount)";
$attrs = ["mail"];
$ldap->search($filter, $attrs);
$info = $ldap->fetch();
// To be developped properly to take Supann and other Mail attributes into consideration.
if (!empty($info["mail"][0]) && isset($info["mail"][0])) {
// For some obscur reasons this attributes won't save in LDAP.
$this->attributesAccess['fdTasksEmailsFromdDN']->setValue($info["mail"][0]);
print_r($this->attributesAccess['fdTasksEmailsFromdDN']->getValue());
}
}
}
return parent::shouldSave();
}
}
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