mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:17:02 +02:00
improved group handling
This commit is contained in:
@ -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(); }
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user