mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 07:32:00 +01:00
enhanced accounting
This commit is contained in:
parent
5b6d7d60a1
commit
b36386676b
@ -15,7 +15,9 @@ class ControllerAccountingAccounting extends Controller {
|
|||||||
$this->load->model('user/user');
|
$this->load->model('user/user');
|
||||||
$this->load->model('group/group');
|
$this->load->model('group/group');
|
||||||
$this->load->model('accounting/accounting');
|
$this->load->model('accounting/accounting');
|
||||||
$counters = new ModelAccountingAccounting();
|
if(ENABLE_SAAS == 1) {
|
||||||
|
$this->load->model('saas/ldap');
|
||||||
|
}
|
||||||
|
|
||||||
$this->data['page'] = 0;
|
$this->data['page'] = 0;
|
||||||
$this->data['page_len'] = get_page_length();
|
$this->data['page_len'] = get_page_length();
|
||||||
@ -58,16 +60,31 @@ class ControllerAccountingAccounting extends Controller {
|
|||||||
if(@$this->request->get['view'] == "email") {
|
if(@$this->request->get['view'] == "email") {
|
||||||
$this->data['view'] = 'email';
|
$this->data['view'] = 'email';
|
||||||
$this->data['viewname'] = $this->data['text_email'];
|
$this->data['viewname'] = $this->data['text_email'];
|
||||||
$this->data['accounting'] = $counters->get_accounting('email',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
$this->data['accounting'] = $this->model_accounting_accounting->get_accounting('email',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||||
$this->data['total_records'] = $counters->count_accounting('email',$this->data['search']);
|
$this->data['total_records'] = $this->model_accounting_accounting->count_accounting('email',$this->data['search']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@$this->request->get['view'] == "domain") {
|
if(@$this->request->get['view'] == "domain") {
|
||||||
$this->data['view'] = 'domain';
|
$this->data['view'] = 'domain';
|
||||||
$this->data['viewname'] = $this->data['text_domain'];
|
$this->data['viewname'] = $this->data['text_domain'];
|
||||||
$this->data['accounting'] = $counters->get_accounting('domain',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
$this->data['accounting'] = $this->model_accounting_accounting->get_accounting('domain',$this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
|
||||||
$this->data['total_records'] = $counters->count_accounting('domain',$this->data['search']);
|
$this->data['total_records'] = $this->model_accounting_accounting->count_accounting('domain',$this->data['search']);
|
||||||
|
|
||||||
|
if(ENABLE_SAAS == 1) {
|
||||||
|
$this->data['accounts'] = array();
|
||||||
|
|
||||||
|
foreach($this->data['accounting'] as $a) {
|
||||||
|
$this->data['accounts'][$a['item']] = $this->model_saas_ldap->get_accounts_in_domain($a['item']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(@$this->request->get['view'] == "accounts" && isset($this->request->get['domain'])) {
|
||||||
|
$this->template = "accounting/accounts.tpl";
|
||||||
|
$this->data['domain'] = $this->request->get['domain'];
|
||||||
|
$this->data['accounts'] = $this->model_saas_ldap->get_accounts_in_domain($this->request->get['domain']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if($this->data['accounting']) {
|
if($this->data['accounting']) {
|
||||||
foreach($this->data['accounting'] as $id=>$row) {
|
foreach($this->data['accounting'] as $id=>$row) {
|
||||||
|
@ -55,6 +55,42 @@ class ModelSaasLdap extends Model
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_accounts_in_domain($domain = '') {
|
||||||
|
$ldap_type = '';
|
||||||
|
$ldap_host = LDAP_HOST;
|
||||||
|
$ldap_base_dn = LDAP_BASE_DN;
|
||||||
|
$ldap_helper_dn = LDAP_HELPER_DN;
|
||||||
|
$ldap_helper_password = LDAP_HELPER_PASSWORD;
|
||||||
|
|
||||||
|
if(ENABLE_SAAS == 1) {
|
||||||
|
$a = $this->model_saas_ldap->get_ldap_params_by_email("aaa@" . $domain);
|
||||||
|
|
||||||
|
if(count($a) >= 5) {
|
||||||
|
$ldap_type = $a[0];
|
||||||
|
$ldap_host = $a[1];
|
||||||
|
$ldap_base_dn = $a[2];
|
||||||
|
$ldap_helper_dn = $a[3];
|
||||||
|
$ldap_helper_password = $a[4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list($ldap_mail_attr, $ldap_account_objectclass, $ldap_distributionlist_attr, $ldap_distributionlist_objectclass) = get_ldap_attribute_names($ldap_type);
|
||||||
|
|
||||||
|
if($ldap_host == '' || $ldap_helper_password == '') { return array(); }
|
||||||
|
|
||||||
|
$ldap = new LDAP($ldap_host, $ldap_helper_dn, $ldap_helper_password);
|
||||||
|
|
||||||
|
if($ldap->is_bind_ok()) {
|
||||||
|
|
||||||
|
$query = $ldap->query($ldap_base_dn, "(&(objectClass=$ldap_account_objectclass)($ldap_mail_attr=*@$domain))", array($ldap_mail_attr));
|
||||||
|
|
||||||
|
if($query->num_rows > 0) { asort($query->rows); return $query->rows; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -62,60 +62,28 @@ class ModelUserAuth extends Model {
|
|||||||
|
|
||||||
|
|
||||||
private function checkLoginAgainstLDAP($username = '', $password = '') {
|
private function checkLoginAgainstLDAP($username = '', $password = '') {
|
||||||
|
$ldap_type = '';
|
||||||
$ldap_host = LDAP_HOST;
|
$ldap_host = LDAP_HOST;
|
||||||
$ldap_base_dn = LDAP_BASE_DN;
|
$ldap_base_dn = LDAP_BASE_DN;
|
||||||
$ldap_helper_dn = LDAP_HELPER_DN;
|
$ldap_helper_dn = LDAP_HELPER_DN;
|
||||||
$ldap_helper_password = LDAP_HELPER_PASSWORD;
|
$ldap_helper_password = LDAP_HELPER_PASSWORD;
|
||||||
|
|
||||||
$ldap_mail_attr = LDAP_MAIL_ATTR;
|
|
||||||
$ldap_account_objectclass = LDAP_ACCOUNT_OBJECTCLASS;
|
|
||||||
$ldap_distributionlist_attr = LDAP_DISTRIBUTIONLIST_ATTR;
|
|
||||||
$ldap_distributionlist_objectclass = LDAP_DISTRIBUTIONLIST_OBJECTCLASS;
|
|
||||||
|
|
||||||
if(ENABLE_SAAS == 1) {
|
if(ENABLE_SAAS == 1) {
|
||||||
$a = $this->model_saas_ldap->get_ldap_params_by_email($username);
|
$a = $this->model_saas_ldap->get_ldap_params_by_email($username);
|
||||||
|
|
||||||
|
if(count($a) >= 5) {
|
||||||
$ldap_type = $a[0];
|
$ldap_type = $a[0];
|
||||||
$ldap_host = $a[1];
|
$ldap_host = $a[1];
|
||||||
$ldap_base_dn = $a[2];
|
$ldap_base_dn = $a[2];
|
||||||
$ldap_helper_dn = $a[3];
|
$ldap_helper_dn = $a[3];
|
||||||
$ldap_helper_password = $a[4];
|
$ldap_helper_password = $a[4];
|
||||||
|
|
||||||
switch ($ldap_type) {
|
|
||||||
|
|
||||||
case 'AD':
|
|
||||||
$ldap_mail_attr = 'mail';
|
|
||||||
$ldap_account_objectclass = 'user';
|
|
||||||
$ldap_distributionlist_attr = 'member';
|
|
||||||
$ldap_distributionlist_objectclass = 'group';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'zimbra':
|
|
||||||
$ldap_mail_attr = 'mail';
|
|
||||||
$ldap_account_objectclass = 'zimbraAccount';
|
|
||||||
$ldap_distributionlist_attr = 'zimbraMailForwardingAddress';
|
|
||||||
$ldap_distributionlist_objectclass = 'zimbraDistributionList';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'iredmail':
|
|
||||||
$ldap_mail_attr = 'mail';
|
|
||||||
$ldap_account_objectclass = 'mailUser';
|
|
||||||
$ldap_distributionlist_attr = 'memberOfGroup';
|
|
||||||
$ldap_distributionlist_objectclass = 'mailList';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'lotus':
|
|
||||||
$ldap_mail_attr = 'mail';
|
|
||||||
$ldap_account_objectclass = 'dominoPerson';
|
|
||||||
$ldap_distributionlist_attr = 'mail';
|
|
||||||
$ldap_distributionlist_objectclass = 'dominoGroup';
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list($ldap_mail_attr, $ldap_account_objectclass, $ldap_distributionlist_attr, $ldap_distributionlist_objectclass) = get_ldap_attribute_names($ldap_type);
|
||||||
|
|
||||||
|
if($ldap_host == '' || $ldap_helper_password == '') { return 0; }
|
||||||
|
|
||||||
$ldap = new LDAP($ldap_host, $ldap_helper_dn, $ldap_helper_password);
|
$ldap = new LDAP($ldap_host, $ldap_helper_dn, $ldap_helper_password);
|
||||||
|
|
||||||
if($ldap->is_bind_ok()) {
|
if($ldap->is_bind_ok()) {
|
||||||
|
@ -492,5 +492,48 @@ function safe_feof($fp, &$start = NULL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_ldap_attribute_names($ldap_type = '') {
|
||||||
|
|
||||||
|
$ldap_mail_attr = LDAP_MAIL_ATTR;
|
||||||
|
$ldap_account_objectclass = LDAP_ACCOUNT_OBJECTCLASS;
|
||||||
|
$ldap_distributionlist_attr = LDAP_DISTRIBUTIONLIST_ATTR;
|
||||||
|
$ldap_distributionlist_objectclass = LDAP_DISTRIBUTIONLIST_OBJECTCLASS;
|
||||||
|
|
||||||
|
switch ($ldap_type) {
|
||||||
|
|
||||||
|
case 'AD':
|
||||||
|
$ldap_mail_attr = 'mail';
|
||||||
|
$ldap_account_objectclass = 'user';
|
||||||
|
$ldap_distributionlist_attr = 'member';
|
||||||
|
$ldap_distributionlist_objectclass = 'group';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'zimbra':
|
||||||
|
$ldap_mail_attr = 'mail';
|
||||||
|
$ldap_account_objectclass = 'zimbraAccount';
|
||||||
|
$ldap_distributionlist_attr = 'zimbraMailForwardingAddress';
|
||||||
|
$ldap_distributionlist_objectclass = 'zimbraDistributionList';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'iredmail':
|
||||||
|
$ldap_mail_attr = 'mail';
|
||||||
|
$ldap_account_objectclass = 'mailUser';
|
||||||
|
$ldap_distributionlist_attr = 'memberOfGroup';
|
||||||
|
$ldap_distributionlist_objectclass = 'mailList';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'lotus':
|
||||||
|
$ldap_mail_attr = 'mail';
|
||||||
|
$ldap_account_objectclass = 'dominoPerson';
|
||||||
|
$ldap_distributionlist_attr = 'mail';
|
||||||
|
$ldap_distributionlist_objectclass = 'dominoGroup';
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($ldap_mail_attr, $ldap_account_objectclass, $ldap_distributionlist_attr, $ldap_distributionlist_objectclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -28,24 +28,34 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3"> </th>
|
<th colspan="3"> </th>
|
||||||
<th colspan="3">Sent</th>
|
<th colspan="3"><?php print $text_sent; ?></th>
|
||||||
<th colspan="3">Received</th>
|
<th colspan="3"><?php print $text_received; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $viewname; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=item&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=item&order=1"><i class="icon-chevron-down"></i></a></th>
|
<th><?php echo $viewname; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=item&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=item&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
<th>Oldest Record <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=oldest&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=oldest&order=1"><i class="icon-chevron-down"></i></a></th>
|
|
||||||
<th>Newest Record <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=newest&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=newest&order=1"><i class="icon-chevron-down"></i></a></th>
|
<?php if(ENABLE_SAAS == 1) { ?>
|
||||||
<th>Items <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sent&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sent&order=1"><i class="icon-chevron-down"></i></a></th>
|
<th><?php print $text_users; ?></th>
|
||||||
<th>Size <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentsize&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentsize&order=1"><i class="icon-chevron-down"></i></a></th>
|
<?php } ?>
|
||||||
<th>Avg Size <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentavg&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentavg&order=1"><i class="icon-chevron-down"></i></a></th>
|
|
||||||
<th>Items <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recd&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recd&order=1"><i class="icon-chevron-down"></i></a></th>
|
<th><?php print $text_oldest_record; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=oldest&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=oldest&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
<th>Size <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdsize&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdsize&order=1"><i class="icon-chevron-down"></i></a></th>
|
<th><?php print $text_newest_record; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=newest&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=newest&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
<th>Avg Size <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdavg&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdavg&order=1"><i class="icon-chevron-down"></i></a></th>
|
<th><?php print $text_items; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sent&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sent&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
|
<th><?php print $text_size; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentsize&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentsize&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
|
<th><?php print $text_average_size; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentavg&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=sentavg&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
|
<th><?php print $text_items; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recd&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recd&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
|
<th><?php print $text_size; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdsize&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdsize&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
|
<th><?php print $text_average_size; ?> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdavg&order=0"><i class="icon-chevron-up"></i></a> <a href="index.php?route=accounting/accounting&view=<?php echo $view; ?>&sort=recdavg&order=1"><i class="icon-chevron-down"></i></a></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php foreach($accounting as $details) {?>
|
<?php foreach($accounting as $details) {?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $details['item']; ?></td>
|
<td><?php echo $details['item']; ?></td>
|
||||||
|
|
||||||
|
<?php if(ENABLE_SAAS == 1) { ?>
|
||||||
|
<td><a href="index.php?route=accounting/accounting&view=accounts&domain=<?php echo $details['item']; ?>"><?php echo count($accounts[$details['item']]); ?></a></td>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<td><?php echo date("d M Y",$details['oldest']); ?></td>
|
<td><?php echo date("d M Y",$details['oldest']); ?></td>
|
||||||
<td><?php echo date("d M Y",$details['newest']); ?></td>
|
<td><?php echo date("d M Y",$details['newest']); ?></td>
|
||||||
<td>
|
<td>
|
||||||
@ -84,6 +94,6 @@
|
|||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='6'>No Emails Found</td>
|
<td colspan='6'><?php print $text_no_email_found; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
32
webui/view/theme/default/templates/accounting/accounts.tpl
Normal file
32
webui/view/theme/default/templates/accounting/accounts.tpl
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
<p>
|
||||||
|
<?php if ($view == 'email') { echo '<strong>'.$text_accounting_email.'</strong>'; } else { echo '<a href="index.php?route=accounting/accounting&view=email">'.$text_accounting_email.'</a>'; } ?> |
|
||||||
|
<?php if ($view == 'domain') { echo '<strong>'.$text_accounting_domain.'</strong>'; } else { echo '<a href="index.php?route=accounting/accounting&view=domain">'.$text_accounting_domain.'</a>'; } ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><a href="index.php?route=accounting/accounting&view=domain"><?php print $text_back; ?></a></p>
|
||||||
|
|
||||||
|
<?php if(count($accounts) > 0) { ?>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?php echo $text_email; ?> (@<?php print $domain; ?>) </th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php foreach($accounts as $a) {?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $a['mail']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php } else { ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php print $text_no_email_found; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<p><a href="index.php?route=accounting/accounting&view=domain"><?php print $text_back; ?></a></p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user