improved group handling

This commit is contained in:
SJ
2012-06-27 11:17:23 +02:00
parent a631595e5f
commit ee910e7735
14 changed files with 221 additions and 16 deletions

View File

@ -140,10 +140,12 @@ class ModelGroupGroup extends Model {
}
public function get_emails_by_string($s = '') {
if(strlen($s) < 2) { return array(); }
public function get_emails_by_string($s = '', $page = 0, $page_len = PAGE_LEN) {
$from = (int)$page * (int)$page_len;
$query = $this->db->query("SELECT email FROM `" . TABLE_EMAIL . "` WHERE email LIKE ? ORDER BY email ASC", array($s . "%") );
if(strlen($s) < 1) { return array(); }
$query = $this->db->query("SELECT email FROM `" . TABLE_EMAIL . "` WHERE email LIKE ? ORDER BY email ASC LIMIT " . (int)$from . ", " . (int)$page_len, array($s . "%") );
if(isset($query->rows)) { return $query->rows; }
@ -151,6 +153,15 @@ class ModelGroupGroup extends Model {
}
public function count_emails($s = '') {
if(strlen($s) < 1) { return 0; }
$query = $this->db->query("SELECT COUNT(*) AS num FROM `" . TABLE_EMAIL . "` WHERE email LIKE ?", array($s . "%") );
return $query->row['num'];
}
public function get_groups_by_string($s = '') {
if(strlen($s) < 2) { return array(); }

View File

@ -380,6 +380,7 @@ class ModelUserUser extends Model {
private function update_group_settings($uid = -1, $group = '') {
$__g = array();
if($uid <= 0 || $group == '') { return 0; }
@ -398,7 +399,10 @@ class ModelUserUser extends Model {
foreach($group as $g) {
$g = rtrim($g);
$query = $this->db->query("INSERT INTO `" . TABLE_GROUP_USER . "` (id, uid) VALUES(?,?)", array($groups[$g], (int)$uid));
if(!isset($__g[$groups[$g]])) {
$query = $this->db->query("INSERT INTO `" . TABLE_GROUP_USER . "` (id, uid) VALUES(?,?)", array($groups[$g], (int)$uid));
$__g[$groups[$g]] = 1;
}
}
return 1;