mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:41:59 +01:00
Improved the ldap group email detection and display
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
890a00f46f
commit
6716bec68c
@ -489,12 +489,10 @@ class ModelSearchSearch extends Model {
|
||||
|
||||
if(isset($query->rows)) {
|
||||
foreach($query->rows as $r) {
|
||||
if(!isset($rcpt[$r['id']]) && !in_array($r['to'], $SUPPRESS_RECIPIENTS)) {
|
||||
$srcpt[$r['id']] = $r['to'];
|
||||
$rcpt[$r['id']] = $r['to'];
|
||||
}
|
||||
else {
|
||||
if(Registry::get('auditor_user') == 1) { $rcpt[$r['id']] .= ",\n" . $r['to']; }
|
||||
if(!isset($rcpt[$r['id']])) { $rcpt[$r['id']] = []; }
|
||||
|
||||
if(Registry::get('auditor_user') == 1 || !in_array($r['to'], $SUPPRESS_RECIPIENTS)) {
|
||||
array_push($rcpt[$r['id']], $r['to']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -542,8 +540,8 @@ class ModelSearchSearch extends Model {
|
||||
$m['shortfrom'] = make_short_string($m['from'], MAX_CGI_FROM_SUBJ_LEN);
|
||||
$m['from'] = escape_gt_lt_quote_symbols($m['from']);
|
||||
|
||||
isset($srcpt[$m['id']]) ? $m['shortto'] = $srcpt[$m['id']] : $m['shortto'] = '';
|
||||
isset($rcpt[$m['id']]) ? $m['to'] = $rcpt[$m['id']] : $m['to'] = '';
|
||||
$m['shortto'] = make_short_string($this->get_preferred_recipient($rcpt[$m['id']]), MAX_CGI_FROM_SUBJ_LEN);
|
||||
$m['to'] = escape_gt_lt_quote_symbols($m['to']);
|
||||
|
||||
|
||||
@ -586,6 +584,26 @@ class ModelSearchSearch extends Model {
|
||||
}
|
||||
|
||||
|
||||
private function get_preferred_recipient($arr = []) {
|
||||
$result = '';
|
||||
|
||||
$session = Registry::get('session');
|
||||
$group_emails = $session->get('group_emails');
|
||||
$user_emails = $session->get('user_emails');
|
||||
|
||||
if(count($arr) < 2 || (!$group_emails && !$user_emails) ) { return $arr[0]; }
|
||||
|
||||
foreach ($arr as $a) {
|
||||
if($result == '' && in_array($a, $group_emails)) { $result = $a; }
|
||||
if(in_array($a, $user_emails)) { $result = $a; }
|
||||
}
|
||||
|
||||
if($result == '') { $result = $arr[0]; }
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function get_message_addresses_in_my_domain($id = '') {
|
||||
$addr = array();
|
||||
$domains = array();
|
||||
|
@ -234,7 +234,7 @@ class ModelUserAuth extends Model {
|
||||
if($this->check_ldap_membership($ldap_auditor_member_dn, $query->rows) == 1) { $role = 2; }
|
||||
if($this->check_ldap_membership($ldap_admin_member_dn, $query->rows) == 1) { $role = 1; }
|
||||
|
||||
$emails = $this->get_email_array_from_ldap_attr($query->rows);
|
||||
$emails = $this->get_email_array_from_ldap_attr($query->rows, $ldap_distributionlist_objectclass);
|
||||
|
||||
$extra_emails = $this->model_user_user->get_email_addresses_from_groups($emails);
|
||||
$emails = array_merge($emails, $extra_emails);
|
||||
@ -292,11 +292,19 @@ class ModelUserAuth extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function get_email_array_from_ldap_attr($e = array()) {
|
||||
public function get_email_array_from_ldap_attr($e = array(), $group_object_class) {
|
||||
global $mailattrs;
|
||||
$data = [];
|
||||
$group_emails = [];
|
||||
$user_emails = [];
|
||||
|
||||
foreach($e as $a) {
|
||||
$group_object = 0;
|
||||
|
||||
if($group_object_class && in_array($group_object_class, $a['objectclass'])) {
|
||||
$group_object = 1;
|
||||
}
|
||||
|
||||
if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking ldap entry dn: " . $a['dn'] . ", cn: " . $a['cn']); }
|
||||
|
||||
foreach ($mailattrs as $mailattr) {
|
||||
@ -316,7 +324,15 @@ class ModelUserAuth extends Model {
|
||||
}
|
||||
|
||||
$email = preg_replace("/^([\w]+)\:/i", "", $a[$mailattr][$i]);
|
||||
if(validemail($email) && !in_array($email, $data)) { array_push($data, $email); }
|
||||
if(validemail($email)) {
|
||||
if(!in_array($email, $data)) { array_push($data, $email); }
|
||||
|
||||
if($group_object) {
|
||||
if(!in_array($email, $group_emails)) { array_push($group_emails, $email); }
|
||||
} else {
|
||||
if(!in_array($email, $user_emails)) { array_push($user_emails, $email); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,12 +340,25 @@ class ModelUserAuth extends Model {
|
||||
if(LOG_LEVEL >= DEBUG) { syslog(LOG_INFO, "checking entry #2: " . $a[$mailattr]); }
|
||||
|
||||
$email = strtolower(preg_replace("/^([\w]+)\:/i", "", $a[$mailattr]));
|
||||
if(validemail($email) && !in_array($email, $data)) { array_push($data, $email); }
|
||||
if(validemail($email)) {
|
||||
if(!in_array($email, $data)) { array_push($data, $email); }
|
||||
|
||||
if($group_object) {
|
||||
if(!in_array($email, $group_emails)) { array_push($group_emails, $email); }
|
||||
} else {
|
||||
if(!in_array($email, $user_emails)) { array_push($user_emails, $email); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$session = Registry::get('session');
|
||||
|
||||
$session->set("user_emails", $user_emails);
|
||||
$session->set("group_emails", $group_emails);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
<td id="c2_r<?php print $i; ?>" class="resultcell id"><?php print ($page*$page_len) + $i + 1; ?></td>
|
||||
<td id="c3_r<?php print $i; ?>" class="resultcell date"><?php print $message['date']; ?></td>
|
||||
<td id="c4_r<?php print $i; ?>" class="resultcell from"><?php if($message['from'] != $message['shortfrom']) { ?><span title="<?php print $message['from']; ?>"><?php print $message['shortfrom']; ?></span><?php } else { print $message['from']; } ?></td>
|
||||
<td id="c5_r<?php print $i; ?>" class="resultcell to"><?php if($message['to'] != $message['shortto']) { ?><span title="<?php print $message['to']; ?>"><?php print $message['shortto']; ?> <i class=" muted icon-group"></i></span><?php } else { print $message['to']; } ?></td>
|
||||
<td id="c5_r<?php print $i; ?>" class="resultcell to"><?php if(count($message['to']) > 1) { ?><span title="<?php print implode("\n", $message['to']); ?>"><?php print $message['shortto']; ?> <i class="muted icon-group"></i></span><?php } else { print $message['shortto']; } ?></td>
|
||||
|
||||
<td id="c6_r<?php print $i; ?>" class="resultcell subject"><a href="#" <?php if($message['deleted'] == 1) { ?>class="xxx"<?php } ?>><?php print $message['subject']; ?></a><?php if(ENABLE_REFERENCES == 1 && $message['reference']) { ?> <a href="#" <?php if($message['deleted'] == 1) { ?>class="xxx"<?php } ?> title="<?php print $text_conversation_available; ?>" onclick="$('#ref').val('<?php print $message['reference']; ?>'); Piler.expert(this);">[+]</span></a><?php } ?><?php if($message['private'] == 1) { ?> <span class="private">P</span><?php } ?></td>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user