fixed the group email autocomplete stuff

This commit is contained in:
SJ 2013-08-22 22:10:52 +02:00
parent 760a76121a
commit 9e88184509
5 changed files with 28 additions and 6 deletions

View File

@ -168,16 +168,38 @@ class ModelGroupGroup extends Model {
}
}
sort($emails);
if(strlen($s) == 1 && ENABLE_LDAP_AUTH == 1) {
$emails = array_slice($emails, $page * $page_len, $page_len);
}
return $emails;
}
public function count_emails($s = '') {
if(strlen($s) < 1) { return 0; }
$count = 0;
if(strlen($s) < 1) { return $count; }
if(ENABLE_LDAP_AUTH == 1) {
$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 . "=" . $s . "*))", array());
if(isset($query->rows)) {
$count = $query->num_rows;
}
}
}
$query = $this->db->query("SELECT COUNT(*) AS num FROM `" . TABLE_EMAIL . "` WHERE email LIKE ?", array($s . "%") );
return $query->row['num'];
$count += $query->row['num'];
return $count;
}

View File

@ -30,7 +30,7 @@
<label class="control-label" for="throwaway"><?php print $text_select_letter; ?>:</label>
<div class="controls">
<?php foreach(Registry::get('letters') as $letter) { ?>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400');" ><?php print $letter; ?></a>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400,scroll=yes');" ><?php print $letter; ?></a>
<?php } ?>
</div>
</div>

View File

@ -44,7 +44,7 @@
<label class="control-label" for="throwaway"><?php print $text_select_letter; ?>:</label>
<div class="controls">
<?php foreach(Registry::get('letters') as $letter) { ?>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400');" ><?php print $letter; ?></a>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400,scroll=yes');" ><?php print $letter; ?></a>
<?php } ?>
</div>
</div>

View File

@ -21,7 +21,7 @@
<div class="domaincell"><textarea style="height:280px;" name="email" id="email" class="span5"><?php if(isset($post['email'])){ print $post['email']; } ?></textarea></div>
<div class="domaincell">
<?php foreach(Registry::get('letters') as $letter) { ?>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400');" ><?php print $letter; ?></a>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400,scroll=yes');" ><?php print $letter; ?></a>
<?php } ?>
</div>
</div>

View File

@ -23,7 +23,7 @@
<div class="domaincell"><textarea style="height:280px;" name="email" id="email" class="span5"><?php if(isset($email)){ print $email; } ?></textarea></div>
<div class="domaincell">
<?php foreach(Registry::get('letters') as $letter) { ?>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400');" ><?php print $letter; ?></a>
<a href="#" onclick="window.open('<?php print SITE_URL; ?>index.php?route=group/email&term=<?php print $letter; ?>', 'aaa', 'width=300,height=400,scroll=yes');" ><?php print $letter; ?></a>
<?php } ?>
</div>
</div>