Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ $config['identity_from_directory_exclude_delete_unmanaged_regex'] = '';
$config['identity_from_directory_update_signatures'] = true;


// Switch for signature creation on missing signatures
//
// true: Create signatures only if the corresponding identity currently has no
// signature (empty). This allows users to customize their signature after the
// initial creation without it being overwritten on subsequent logins.
//
// false: Do not create signatures if signature updates are disabled.
//
// Note: If $config['identity_from_directory_update_signatures'] is true, then
// signatures are overwritten on each login regardless of this option.
$config['identity_from_directory_create_signatures'] = false;


// Signature templates
//
// You can use each key from $config['identity_from_directory_ldap']['fieldmap']
Expand Down
20 changes: 20 additions & 0 deletions identity_from_directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function login_after($args)
// get config and other data needed for further processing
$ldap_config = (array) $this->rc->config->get('identity_from_directory_ldap');
$update_signatures = (bool) $this->rc->config->get('identity_from_directory_update_signatures');
$create_signatures = (bool) $this->rc->config->get('identity_from_directory_create_signatures');
$use_html_signature = (bool) $this->rc->config->get('identity_from_directory_use_html_signature');
$wash_html_signature = (bool) $this->rc->config->get('identity_from_directory_wash_html_signature');
if ($use_html_signature) {
Expand Down Expand Up @@ -178,7 +179,26 @@ public function login_after($args)
'organization' => (array_key_exists('organization', $user_data) ? $user_data['organization'] : ''),
];

// Decide whether to set/overwrite the signature
// - update_signatures: always overwrite
// - create_signatures: set only if the current identity has an empty signature
$should_set_signature = false;
if ($update_signatures) {
$should_set_signature = true;
} elseif ($create_signatures) {
if ($identity_id === 0) {
// New identity => signature is missing
$should_set_signature = true;
} elseif (method_exists($this->rc->user, 'get_identity')) {
$existing_identity = $this->rc->user->get_identity($identity_id);
if (is_array($existing_identity) && array_key_exists('signature', $existing_identity)) {
$existing_signature = (string) $existing_identity['signature'];
$should_set_signature = (trim($existing_signature) === '');
}
}
}

if ($should_set_signature) {
// copy signature template
$signature = $signature_template;

Expand Down