mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:51:59 +01:00
updated the group handling + revised admin permissions
This commit is contained in:
parent
9900f0aed2
commit
095f22c7b2
@ -189,7 +189,6 @@ create index `user_settings_idx` on `user_settings`(`username`);
|
||||
drop table if exists `user`;
|
||||
create table if not exists `user` (
|
||||
`uid` int unsigned not null primary key,
|
||||
`gid` int default 0,
|
||||
`username` char(64) not null unique,
|
||||
`realname` char(64) default null,
|
||||
`password` char(48) default null,
|
||||
@ -198,7 +197,7 @@ create table if not exists `user` (
|
||||
`isadmin` tinyint default 0
|
||||
) Engine=InnoDB;
|
||||
|
||||
insert into `user` (`uid`, `gid`, `username`, `realname`, `password`, `isadmin`, `domain`) values (0, 0, 'admin', 'built-in piler admin', '$1$PItc7d$zsUgON3JRrbdGS11t9JQW1', 1, 'local');
|
||||
insert into `user` (`uid`, `username`, `realname`, `password`, `isadmin`, `domain`) values (0, 'admin', 'built-in piler admin', '$1$PItc7d$zsUgON3JRrbdGS11t9JQW1', 1, 'local');
|
||||
|
||||
drop table if exists `email`;
|
||||
create table if not exists `email` (
|
||||
@ -223,6 +222,14 @@ create table if not exists `group` (
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
||||
create table if not exists `group_user` (
|
||||
`id` bigint unsigned not null,
|
||||
`uid` int unsigned not null,
|
||||
key `group_user_idx` (`id`),
|
||||
key `group_user_idx2` (`uid`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
||||
create table if not exists `group_email` (
|
||||
`id` bigint unsigned not null,
|
||||
`email` char(128) not null,
|
||||
|
@ -10,6 +10,12 @@ create table if not exists `group_email` (
|
||||
key `group_email_idx` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
alter table `user` add column `gid` int default 0;
|
||||
create table if not exists `group_user` (
|
||||
`id` bigint unsigned not null,
|
||||
`uid` int unsigned not null,
|
||||
key `group_user_idx` (`id`),
|
||||
key `group_user_idx2` (`uid`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
|
||||
|
||||
|
@ -81,6 +81,7 @@ define('DB_DATABASE', 'piler');
|
||||
|
||||
define('TABLE_USER', 'user');
|
||||
define('TABLE_GROUP', 'group');
|
||||
define('TABLE_GROUP_USER', 'group_user');
|
||||
define('TABLE_GROUP_EMAIL', 'group_email');
|
||||
define('TABLE_EMAIL', 'email');
|
||||
define('TABLE_META', 'metadata');
|
||||
|
@ -26,6 +26,8 @@ class ControllerGroupAdd extends Controller {
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$ret = 0;
|
||||
|
||||
$this->data['post'] = $this->request->post;
|
||||
|
||||
if($this->validate() == true){
|
||||
$ret = $this->model_group_group->add_group($this->request->post);
|
||||
|
||||
|
@ -38,8 +38,6 @@ class ControllerGroupEdit extends Controller {
|
||||
|
||||
if(Registry::get('admin_user') == 1) {
|
||||
|
||||
$this->data['group'] = $this->model_group_group->get_domain_by_id($this->data['id']);
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
if($this->validate() == true){
|
||||
@ -59,6 +57,7 @@ class ControllerGroupEdit extends Controller {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->data['group'] = $this->model_group_group->get_domain_by_id($this->data['id']);
|
||||
$this->data['email'] = $this->model_group_group->get_emails_by_group_id($this->data['id']);
|
||||
}
|
||||
}
|
||||
|
48
webui/controller/group/email.php
Normal file
48
webui/controller/group/email.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerGroupEmail extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "user/list.tpl";
|
||||
$this->layout = "common/layout-empty";
|
||||
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
$language = Registry::get('language');
|
||||
|
||||
$this->load->model('group/group');
|
||||
|
||||
|
||||
$this->data['term'] = '';
|
||||
|
||||
if(!isset($this->request->get['term']) || strlen($this->request->get['term']) < 2) { die("no data"); }
|
||||
|
||||
|
||||
/* check if we are admin */
|
||||
|
||||
if(Registry::get('admin_user') == 1) {
|
||||
$emails = $this->model_group_group->get_emails_by_string($this->request->get['term']);
|
||||
|
||||
$i = 0;
|
||||
$s = '[ ';
|
||||
|
||||
foreach($emails as $email) {
|
||||
$i++;
|
||||
$s .= '{ "id": "' . $i . '", "value": "' . $email['email'] . '" },';
|
||||
}
|
||||
|
||||
$s = preg_replace("/,$/", "", $s) . " ]";
|
||||
|
||||
print $s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
48
webui/controller/group/group.php
Normal file
48
webui/controller/group/group.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerGroupGroup extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "user/list.tpl";
|
||||
$this->layout = "common/layout-empty";
|
||||
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
$language = Registry::get('language');
|
||||
|
||||
$this->load->model('group/group');
|
||||
|
||||
|
||||
$this->data['term'] = '';
|
||||
|
||||
if(!isset($this->request->get['term']) || strlen($this->request->get['term']) < 2) { die("no data"); }
|
||||
|
||||
|
||||
/* check if we are admin */
|
||||
|
||||
if(Registry::get('admin_user') == 1) {
|
||||
$results = $this->model_group_group->get_groups_by_string($this->request->get['term']);
|
||||
|
||||
$i = 0;
|
||||
$s = '[ ';
|
||||
|
||||
foreach($results as $result) {
|
||||
$i++;
|
||||
$s .= '{ "id": "' . $i . '", "value": "' . $result['groupname'] . '" },';
|
||||
}
|
||||
|
||||
$s = preg_replace("/,$/", "", $s) . " ]";
|
||||
|
||||
print $s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -19,7 +19,7 @@ class ControllerHealthHealth extends Controller {
|
||||
|
||||
/* check if we are admin */
|
||||
|
||||
if(Registry::get('admin_user') != 1 && Registry::get('readonly_admin') != 1 && Registry::get('auditor_admin') != 1) {
|
||||
if(Registry::get('admin_user') != 1 && Registry::get('readonly_admin') != 1) {
|
||||
$this->template = "common/error.tpl";
|
||||
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ class ControllerUserEdit extends Controller {
|
||||
}
|
||||
else {
|
||||
$this->data['user'] = $this->model_user_user->get_user_by_uid($this->data['uid']);
|
||||
$this->data['groups'] = $this->model_group_group->get_groups();
|
||||
|
||||
$this->data['user']['group_membership'] = $this->model_user_user->get_additional_uids($this->data['uid']);
|
||||
$this->data['user']['group'] = $this->model_group_group->get_groups_by_uid($this->data['uid']);
|
||||
|
||||
$this->data['emails'] = $this->model_user_user->get_emails($this->data['user']['username']);
|
||||
|
||||
|
@ -86,6 +86,7 @@ $_['text_empty_search_result'] = "Empty search result";
|
||||
$_['text_enable'] = "Enable";
|
||||
$_['text_enabled'] = "enabled";
|
||||
$_['text_enter_one_email_address_per_line'] = "Enter one email address per line";
|
||||
$_['text_enter_one_group_per_line'] = "Enter one group per line";
|
||||
$_['text_enter_search_terms'] = "Enter your search terms";
|
||||
$_['text_error'] = "Error";
|
||||
$_['text_exact_domain_name_or_email_address'] = "exact domain name or email address";
|
||||
@ -168,6 +169,7 @@ $_['text_memory_usage'] = "Memory usage";
|
||||
$_['text_message'] = "message";
|
||||
$_['text_messages'] = "messages";
|
||||
$_['text_message_text'] = "Message text";
|
||||
$_['text_min_2_chars'] = "Min. 2 characters";
|
||||
$_['text_missing_data'] = "Missing data";
|
||||
$_['text_missing_password'] = "Missing password";
|
||||
$_['text_modify'] = "Modify";
|
||||
@ -245,6 +247,10 @@ $_['text_save_search_terms'] = "Save search terms";
|
||||
$_['text_saved_search_terms'] = "Saved search terms";
|
||||
$_['text_search'] = "Search";
|
||||
$_['text_search2'] = "search";
|
||||
$_['text_search_emails'] = "Search email addresses";
|
||||
$_['text_search_email_to_add'] = "Search email to add";
|
||||
$_['text_search_groups'] = "Search groups";
|
||||
$_['text_search_group_to_add'] = "Search group to add";
|
||||
$_['text_search_terms'] = "Search terms";
|
||||
$_['text_select_action'] = "Select action";
|
||||
$_['text_select_all'] = "Select all";
|
||||
|
@ -86,6 +86,7 @@ $_['text_empty_search_result'] = "Nincs tal
|
||||
$_['text_enable'] = "Engedélyez";
|
||||
$_['text_enabled'] = "engedélyezve";
|
||||
$_['text_enter_one_email_address_per_line'] = "Egy sorba egy email címet írjon";
|
||||
$_['text_enter_one_group_per_line'] = "Egy sorba egy csoportnevet írjon";
|
||||
$_['text_enter_search_terms'] = "Írja be a keresési feltételeket";
|
||||
$_['text_error'] = "Hiba";
|
||||
$_['text_exact_domain_name_or_email_address'] = "pontos domainnév vagy email cím";
|
||||
@ -169,6 +170,7 @@ $_['text_memory_usage'] = "Mem
|
||||
$_['text_message'] = "üzenet";
|
||||
$_['text_messages'] = "üzenet";
|
||||
$_['text_message_text'] = "Levél szöveg";
|
||||
$_['text_min_2_chars'] = "Min. 2 karakter";
|
||||
$_['text_missing_data'] = "Hiányzó adat";
|
||||
$_['text_missing_password'] = "Hiányzó jelszó";
|
||||
$_['text_modify'] = "Módosítás";
|
||||
@ -246,6 +248,10 @@ $_['text_save_search_terms'] = "Keres
|
||||
$_['text_saved_search_terms'] = "Elmentett keresések";
|
||||
$_['text_search'] = "Keresés";
|
||||
$_['text_search2'] = "keresés";
|
||||
$_['text_search_emails'] = "Email címek keresése";
|
||||
$_['text_search_email_to_add'] = "írja be az email cím elejét";
|
||||
$_['text_search_groups'] = "Csoportok keresése";
|
||||
$_['text_search_group_to_add'] = "írja be a csoport nevének elejét";
|
||||
$_['text_search_terms'] = "Keresési feltételek";
|
||||
$_['text_select_action'] = "Művelet választás";
|
||||
$_['text_select_all'] = "Mindegyik kijelölése";
|
||||
|
@ -86,6 +86,7 @@ $_['text_empty_search_result'] = "Nincs találat a keresésre";
|
||||
$_['text_enable'] = "Engedélyez";
|
||||
$_['text_enabled'] = "engedélyezve";
|
||||
$_['text_enter_one_email_address_per_line'] = "Egy sorba egy email címet írjon";
|
||||
$_['text_enter_one_group_per_line'] = "Egy sorba egy csoportnevet írjon";
|
||||
$_['text_enter_search_terms'] = "Írja be a keresési feltételeket";
|
||||
$_['text_error'] = "Hiba";
|
||||
$_['text_exact_domain_name_or_email_address'] = "pontos domainnév vagy email cím";
|
||||
@ -169,6 +170,7 @@ $_['text_memory_usage'] = "Memória használat";
|
||||
$_['text_message'] = "üzenet";
|
||||
$_['text_messages'] = "üzenet";
|
||||
$_['text_message_text'] = "Levél szöveg";
|
||||
$_['text_min_2_chars'] = "Min. 2 karakter";
|
||||
$_['text_missing_data'] = "Hiányzó adat";
|
||||
$_['text_missing_password'] = "Hiányzó jelszó";
|
||||
$_['text_modify'] = "Módosítás";
|
||||
@ -246,6 +248,10 @@ $_['text_save_search_terms'] = "Keresési feltétel mentése";
|
||||
$_['text_saved_search_terms'] = "Elmentett keresések";
|
||||
$_['text_search'] = "Keresés";
|
||||
$_['text_search2'] = "keresés";
|
||||
$_['text_search_emails'] = "Email címek keresése";
|
||||
$_['text_search_email_to_add'] = "írja be az email cím elejét";
|
||||
$_['text_search_groups'] = "Csoportok keresése";
|
||||
$_['text_search_group_to_add'] = "írja be a csoport nevének elejét";
|
||||
$_['text_search_terms'] = "Keresési feltételek";
|
||||
$_['text_select_action'] = "Művelet választás";
|
||||
$_['text_select_all'] = "Mindegyik kijelölése";
|
||||
|
@ -140,6 +140,41 @@ class ModelGroupGroup extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function get_emails_by_string($s = '') {
|
||||
if(strlen($s) < 2) { return array(); }
|
||||
|
||||
$query = $this->db->query("SELECT email FROM `" . TABLE_EMAIL . "` WHERE email LIKE ? ORDER BY email ASC", array($s . "%") );
|
||||
|
||||
if(isset($query->rows)) { return $query->rows; }
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
public function get_groups_by_string($s = '') {
|
||||
if(strlen($s) < 2) { return array(); }
|
||||
|
||||
$query = $this->db->query("SELECT groupname FROM `" . TABLE_GROUP . "` WHERE groupname LIKE ? ORDER BY groupname ASC", array($s . "%") );
|
||||
|
||||
if(isset($query->rows)) { return $query->rows; }
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
public function get_groups_by_uid($uid = 0) {
|
||||
$groups = '';
|
||||
|
||||
$query = $this->db->query("SELECT `" . TABLE_GROUP_USER . "`.id, groupname FROM `" . TABLE_GROUP_USER . "`, `" . TABLE_GROUP . "` WHERE `" . TABLE_GROUP_USER . "`.id=`" . TABLE_GROUP . "`.id AND uid=?", array($uid) );
|
||||
|
||||
if(isset($query->rows)) {
|
||||
foreach ($query->rows as $q) { $groups .= "\n" . $q['groupname']; }
|
||||
}
|
||||
|
||||
return preg_replace("/^\n/", "", $groups);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -57,8 +57,6 @@ class ModelSearchMessage extends Model {
|
||||
public function get_message_headers($id = '') {
|
||||
$data = '';
|
||||
|
||||
//$f = $this->get_store_path($id);
|
||||
//$msg = $this->decrypt_and_uncompress_file($f.".m");
|
||||
$msg = $this->get_raw_message($id);
|
||||
|
||||
$pos = strpos($msg, "\n\r\n");
|
||||
@ -95,8 +93,6 @@ class ModelSearchMessage extends Model {
|
||||
|
||||
$msg = $this->get_raw_message($id);
|
||||
|
||||
//print "a: $msg\n";
|
||||
|
||||
$a = explode("\n", $msg); $msg = "";
|
||||
|
||||
while(list($k, $l) = each($a)){
|
||||
@ -166,7 +162,7 @@ class ModelSearchMessage extends Model {
|
||||
if($this->check_boundary($boundary, $l) == 1){
|
||||
|
||||
if($text_plain == 1 || $has_text_plain == 0) {
|
||||
$message .= $this->flush_body_chunk($body_chunk, $charset, $qp, $base64, $text_plain, $text_html);
|
||||
$message .= $this->flush_body_chunk($body_chunk, $charset, $qp, $base64, $text_plain, $text_html);
|
||||
}
|
||||
|
||||
$text_plain = $text_html = $qp = $base64 = 0;
|
||||
@ -235,7 +231,6 @@ class ModelSearchMessage extends Model {
|
||||
$chunk = preg_replace("/</", "<", $chunk);
|
||||
$chunk = preg_replace("/>/", ">", $chunk);
|
||||
|
||||
//$chunk = "<pre>\n" . $this->print_nicely($chunk) . "</pre>\n";
|
||||
$chunk = preg_replace("/\n/", "<br />\n", $chunk);
|
||||
$chunk = "\n" . $this->print_nicely($chunk);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class ModelSearchSearch extends Model {
|
||||
$data['subject'] = $this->fixup_sphinx_operators($data['subject']);
|
||||
|
||||
|
||||
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) {
|
||||
if(Registry::get('auditor_user') == 1) {
|
||||
if($data['f_from']) { $f1 .= "|" . $data['f_from']; $n_fc++; }
|
||||
if($data['o_from']) { $f1 .= "|" . $data['o_from']; $n_fc++; }
|
||||
if($data['from_domain']) { $fd .= "(@fromdomain " . substr($data['from_domain'], 1, strlen($data['from_domain'])) . ")"; $n_fc++; }
|
||||
@ -174,7 +174,7 @@ class ModelSearchSearch extends Model {
|
||||
private function assemble_simple_query_conditions($data = array(), $sort = 'sent', $order = 'DESC', $sortorder = '', $cache_key = '') {
|
||||
$email = $match = "";
|
||||
|
||||
if(Registry::get('admin_user') == 0 && Registry::get('auditor_user') == 0) {
|
||||
if(Registry::get('auditor_user') == 0) {
|
||||
|
||||
$all_your_addresses = $this->get_all_your_address();
|
||||
|
||||
@ -404,7 +404,7 @@ class ModelSearchSearch extends Model {
|
||||
public function get_message_recipients($id = '') {
|
||||
$rcpt = array();
|
||||
|
||||
if(Registry::get('admin_user') == 0 && Registry::get('auditor_user') == 0) { return $rcpt; }
|
||||
if(Registry::get('auditor_user') == 0) { return $rcpt; }
|
||||
|
||||
$query = $this->db->query("SELECT `to` FROM " . VIEW_MESSAGES . " WHERE piler_id=?", array($id));
|
||||
|
||||
@ -434,7 +434,7 @@ class ModelSearchSearch extends Model {
|
||||
|
||||
if($id == '') { return 0; }
|
||||
|
||||
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) { return 1; }
|
||||
if(Registry::get('auditor_user') == 1) { return 1; }
|
||||
|
||||
array_push($arr, $id);
|
||||
|
||||
@ -463,7 +463,7 @@ class ModelSearchSearch extends Model {
|
||||
|
||||
if(count($id) < 1) { return array(); }
|
||||
|
||||
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) { return $id; }
|
||||
if(Registry::get('auditor_user') == 1) { return $id; }
|
||||
|
||||
$arr = $id;
|
||||
|
||||
|
@ -4,7 +4,7 @@ class ModelUserAuth extends Model {
|
||||
|
||||
public function checkLogin($username = '', $password = '') {
|
||||
|
||||
$query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".gid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($username));
|
||||
$query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($username));
|
||||
|
||||
if(!isset($query->row['password'])) { return 0; }
|
||||
|
||||
@ -14,7 +14,6 @@ class ModelUserAuth extends Model {
|
||||
|
||||
$_SESSION['username'] = $query->row['username'];
|
||||
$_SESSION['uid'] = $query->row['uid'];
|
||||
$_SESSION['gid'] = $query->row['gid'];
|
||||
$_SESSION['admin_user'] = $query->row['isadmin'];
|
||||
$_SESSION['email'] = $username;
|
||||
$_SESSION['domain'] = $query->row['domain'];
|
||||
|
@ -68,7 +68,8 @@ class ModelUserUser extends Model {
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->query("SELECT email FROM `" . TABLE_GROUP_EMAIL . "` WHERE id=?", array($gid));
|
||||
$query = $this->db->query("SELECT `" . TABLE_GROUP_EMAIL . "`.email FROM `" . TABLE_GROUP_EMAIL . "`, `" . TABLE_GROUP_USER . "` WHERE `" . TABLE_GROUP_EMAIL . "`.id=`" . TABLE_GROUP_USER . "`.id and `" . TABLE_GROUP_USER . "`.uid=?", array($uid) );
|
||||
|
||||
|
||||
if(isset($query->rows)) {
|
||||
foreach ($query->rows as $q) {
|
||||
@ -181,14 +182,13 @@ class ModelUserUser extends Model {
|
||||
|
||||
if($page_len > 0) { $limit = " LIMIT " . (int)$from . ", " . (int)$page_len; }
|
||||
|
||||
$query = $this->db->query("SELECT " . TABLE_USER . ".uid, gid, isadmin, username, realname, domain, email FROM " . TABLE_USER . "," . TABLE_EMAIL . " $where_cond group by " . TABLE_USER . ".uid $_order $limit");
|
||||
$query = $this->db->query("SELECT " . TABLE_USER . ".uid, isadmin, username, realname, domain, email FROM " . TABLE_USER . "," . TABLE_EMAIL . " $where_cond group by " . TABLE_USER . ".uid $_order $limit");
|
||||
|
||||
foreach ($query->rows as $q) {
|
||||
|
||||
if(Registry::get('admin_user') == 1 || (isset($q['domain']) && $q['domain'] == $my_domain[0]) ) {
|
||||
$users[] = array(
|
||||
'uid' => $q['uid'],
|
||||
'gid' => $q['gid'],
|
||||
'username' => $q['username'],
|
||||
'realname' => $q['realname'],
|
||||
'domain' => isset($q['domain']) ? $q['domain'] : "",
|
||||
@ -286,7 +286,7 @@ class ModelUserUser extends Model {
|
||||
|
||||
$encrypted_password = crypt($user['password']);
|
||||
|
||||
$query = $this->db->query("INSERT INTO " . TABLE_USER . " (uid, gid, username, realname, password, domain, dn, isadmin) VALUES(?,?,?,?,?,?,?,?)", array((int)$user['uid'], (int)$user['gid'], $user['username'], $user['realname'], $encrypted_password, $user['domain'], @$user['dn'], (int)$user['isadmin']));
|
||||
$query = $this->db->query("INSERT INTO " . TABLE_USER . " (uid, username, realname, password, domain, dn, isadmin) VALUES(?,?,?,?,?,?,?)", array((int)$user['uid'], $user['username'], $user['realname'], $encrypted_password, $user['domain'], @$user['dn'], (int)$user['isadmin']));
|
||||
|
||||
if($query->error == 1 || $this->db->countAffected() == 0){ return $user['username']; }
|
||||
|
||||
@ -297,6 +297,7 @@ class ModelUserUser extends Model {
|
||||
if($ret == 0) { return -2; }
|
||||
}
|
||||
|
||||
$this->update_group_settings((int)$user['uid'], $user['group']);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -350,7 +351,7 @@ class ModelUserUser extends Model {
|
||||
if($this->db->countAffected() != 1) { return 0; }
|
||||
}
|
||||
|
||||
$query = $this->db->query("UPDATE " . TABLE_USER . " SET username=?, realname=?, domain=?, gid=?, dn=?, isadmin=? WHERE uid=?", array($user['username'], $user['realname'], $user['domain'], $user['gid'], @$user['dn'], $user['isadmin'], (int)$user['uid']));
|
||||
$query = $this->db->query("UPDATE " . TABLE_USER . " SET username=?, realname=?, domain=?, dn=?, isadmin=? WHERE uid=?", array($user['username'], $user['realname'], $user['domain'], @$user['dn'], $user['isadmin'], (int)$user['uid']));
|
||||
|
||||
|
||||
/* first, remove all his email addresses */
|
||||
@ -372,6 +373,34 @@ class ModelUserUser extends Model {
|
||||
|
||||
}
|
||||
|
||||
$this->update_group_settings((int)$user['uid'], $user['group']);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
private function update_group_settings($uid = -1, $group = '') {
|
||||
|
||||
if($uid <= 0 || $group == '') { return 0; }
|
||||
|
||||
$query = $this->db->query("DELETE FROM `" . TABLE_GROUP_USER . "` WHERE uid=?", array($uid));
|
||||
|
||||
$query = $this->db->query("SELECT id, groupname FROM `" . TABLE_GROUP . "`");
|
||||
|
||||
$groups = array();
|
||||
|
||||
foreach ($query->rows as $q) {
|
||||
$groups[$q['groupname']] = $q['id'];
|
||||
}
|
||||
|
||||
$group = explode("\n", $group);
|
||||
|
||||
foreach($group as $g) {
|
||||
$g = rtrim($g);
|
||||
|
||||
$query = $this->db->query("INSERT INTO `" . TABLE_GROUP_USER . "` (id, uid) VALUES(?,?)", array($groups[$g], (int)$uid));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -284,8 +284,6 @@ function assemble_search_url($term = '') {
|
||||
|
||||
parse_str($term, $a);
|
||||
|
||||
//print_r($a);
|
||||
|
||||
if(isset($a['search'])) { $term_value = $a['search']; }
|
||||
|
||||
if(isset($a['f'])) {
|
||||
@ -410,28 +408,27 @@ function fetch_url($url = '') {
|
||||
|
||||
|
||||
function fixup_date_condition($field = '', $date1 = 0, $date2 = 0) {
|
||||
$date = "";
|
||||
$date = "";
|
||||
|
||||
if($date1) {
|
||||
list($y,$m,$d) = explode("-", $date1);
|
||||
$date1 = mktime(0, 0, 0, $m, $d, $y);
|
||||
if($date1) {
|
||||
list($y,$m,$d) = explode("-", $date1);
|
||||
$date1 = mktime(0, 0, 0, $m, $d, $y);
|
||||
|
||||
if($date1 > 0) { $date .= "$field >= $date1 "; }
|
||||
if($date1 > 0) { $date .= "$field >= $date1 "; }
|
||||
}
|
||||
|
||||
if($date2) {
|
||||
list($y,$m,$d) = explode("-", $date2);
|
||||
$date2 = mktime(23, 59, 59, $m, $d, $y);
|
||||
|
||||
if($date2 > 0) {
|
||||
if($date) { $date .= " AND "; }
|
||||
$date .= "$field <= $date2 ";
|
||||
}
|
||||
}
|
||||
|
||||
if($date2) {
|
||||
list($y,$m,$d) = explode("-", $date2);
|
||||
$date2 = mktime(23, 59, 59, $m, $d, $y);
|
||||
|
||||
if($date2 > 0) {
|
||||
if($date) { $date .= " AND "; }
|
||||
$date .= "$field <= $date2 ";
|
||||
}
|
||||
}
|
||||
|
||||
//if($date) { $date .= " AND "; }
|
||||
|
||||
return $date;
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
|
@ -523,3 +523,55 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(function() {
|
||||
|
||||
$("#s_piler_email").autocomplete({
|
||||
source: email_search_url,
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
if(ui.item){
|
||||
var prefix = '\n';
|
||||
var a = document.getElementById("email");
|
||||
|
||||
if(a && a.value == '') prefix = '';
|
||||
|
||||
$('#email').val($('#email').val() + prefix + ui.item.value);
|
||||
}
|
||||
|
||||
ui.item.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
$("#s_piler_group").autocomplete({
|
||||
source: group_search_url,
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
if(ui.item){
|
||||
var prefix = '\n';
|
||||
var a = document.getElementById("group");
|
||||
|
||||
if(a && a.value == '') prefix = '';
|
||||
|
||||
$('#group').val($('#group').val() + prefix + ui.item.value);
|
||||
}
|
||||
|
||||
ui.item.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function toggle_hint(id, s, focus) {
|
||||
|
||||
if(focus == 1){
|
||||
if(document.getElementById(id).value == s) document.getElementById(id).value = '';
|
||||
}
|
||||
else {
|
||||
if(document.getElementById(id).value == '') document.getElementById(id).value = s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,6 +65,7 @@
|
||||
.restore_spinner { text-align: center; border: 0px solid black; }
|
||||
|
||||
.text { font: normal 12px Arial, sans-serif; font-weight: bold; text-align:left; width: 408px; }
|
||||
.autocompletetext { font: normal 12px Arial, sans-serif; font-style: italic; color: gray; font-weight: bold; text-align:left; width: 408px; }
|
||||
.ruletext { font: normal 12px Arial, sans-serif; font-weight: bold; text-align:left; width: 365px; }
|
||||
.advtext { font: bold 12px Arial, sans-serif; font-weight: bold; text-align:left; width: 280px; }
|
||||
.tagtext { font: normal 10px Arial, sans-serif; font-weight: bold; text-align:left; width: 265px; }
|
||||
|
@ -16,9 +16,12 @@
|
||||
<script type="text/javascript" src="/view/javascript/jquery-1.7.1.min.js"></script>
|
||||
<script type="text/javascript" src="/view/javascript/jquery-ui-1.8.13.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/view/javascript/jquery.dropdownPlain.js"></script>
|
||||
<script type="text/javascript" src="/view/javascript/colorbox.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var piler_ui_lang = '<?php if(LANG == 'en') { ?>en-GB<?php } else { print LANG; } ?>';
|
||||
var email_search_url = '<?php print SITE_URL; ?>/index.php?route=group/email&';
|
||||
var group_search_url = '<?php print SITE_URL; ?>/index.php?route=group/group&';
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="/view/javascript/piler.js"></script>
|
||||
|
@ -12,13 +12,18 @@
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_email_addresses; ?>*:</div>
|
||||
<div class="domaincell"><?php print $text_search_emails; ?>*:</div>
|
||||
<div class="domaincell"><input type="text" id="s_piler_email" name="s_piler_email" value="<?php print $text_search_email_to_add; ?>" class="autocompletetext" onfocus="javascript:toggle_hint('s_piler_email', '<?php print $text_search_email_to_add; ?>', 1);" onblur="javascript:toggle_hint('s_piler_email', '<?php print $text_search_email_to_add; ?>', 0);" /></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_email_addresses; ?>**:</div>
|
||||
<div class="domaincell"><textarea style="height:280px;" name="email" id="email" class="domain"><?php if(isset($post['email'])){ print $post['email']; } ?></textarea></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell">*: <?php print $text_enter_one_email_address_per_line; ?></div>
|
||||
<div class="domaincell">*: <?php print $text_min_2_chars; ?><br />**: <?php print $text_enter_one_email_address_per_line; ?></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -10,17 +10,22 @@
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_groupname; ?>:</div>
|
||||
<div class="domaincell"><input type="text" name="groupname" value="<?php print $group['groupname']; ?>" class="text" /></div>
|
||||
<div class="domaincell"><input type="text" name="groupname" id="groupname" value="<?php print $group['groupname']; ?>" class="text" /></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_email_addresses; ?>*:</div>
|
||||
<div class="domaincell"><textarea style="height:280px;" name="email" class="domain"><?php if(isset($email)){ print $email; } ?></textarea></div>
|
||||
<div class="domaincell"><?php print $text_search_emails; ?>*:</div>
|
||||
<div class="domaincell"><input type="text" id="s_piler_email" name="s_piler_email" value="<?php print $text_search_email_to_add; ?>" class="autocompletetext" onfocus="javascript:toggle_hint('s_piler_email', '<?php print $text_search_email_to_add; ?>', 1);" onblur="javascript:toggle_hint('s_piler_email', '<?php print $text_search_email_to_add; ?>', 0);" /></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_email_addresses; ?>**:</div>
|
||||
<div class="domaincell"><textarea style="height:280px;" name="email" id="email" class="domain"><?php if(isset($email)){ print $email; } ?></textarea></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell">*: <?php print $text_enter_one_email_address_per_line; ?></div>
|
||||
<div class="domaincell">*: <?php print $text_min_2_chars; ?><br />**: <?php print $text_enter_one_email_address_per_line; ?></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
@ -33,6 +38,7 @@
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<p> </p>
|
||||
<p><a href="index.php?route=group/remove&id=<?php print $group['id']; ?>&group=<?php print $group['groupname']; ?>"><?php print $text_remove_this_group; ?>: <?php print $group['groupname']; ?></a></p>
|
||||
<p> </p>
|
||||
|
@ -32,17 +32,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_search_groups; ?>*:</div>
|
||||
<div class="domaincell"><input type="text" id="s_piler_group" name="s_piler_group" value="<?php print $text_search_group_to_add; ?>" class="autocompletetext" onfocus="javascript:toggle_hint('s_piler_group', '<?php print $text_search_group_to_add; ?>', 1);" onblur="javascript:toggle_hint('s_piler_group', '<?php print $text_search_group_to_add; ?>', 0);" /></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_groups; ?>:</div>
|
||||
<div class="domaincell">
|
||||
<select name="gid">
|
||||
<option value="0"<?php if(isset($post) && $post['gid'] == 0){ ?> selected="selected"<?php } ?>>-</option>
|
||||
<?php foreach ($groups as $group) { ?>
|
||||
<option value="<?php print $group['id']; ?>"<?php if(isset($post) && $post['gid'] == $group['id']){ ?> selected="selected"<?php } ?>><?php print $group['groupname']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="domaincell"><?php print $text_groups; ?>**:</div>
|
||||
<div class="domaincell"><textarea style="height:80px;" name="group" id="group" class="domain"><?php if(isset($post['group'])){ print $post['group']; } ?></textarea></div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -76,6 +73,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell">*: <?php print $text_min_2_chars; ?><br />**: <?php print $text_enter_one_group_per_line; ?></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell"><input type="submit" value="<?php print $text_add; ?>" /><input type="reset" value="<?php print $text_cancel; ?>" /></div>
|
||||
|
@ -35,17 +35,14 @@
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_groups; ?>:</div>
|
||||
<div class="domaincell">
|
||||
<select name="gid">
|
||||
<option value="0"<?php if($user['gid'] == 0){ ?> selected="selected"<?php } ?>>-</option>
|
||||
<?php foreach ($groups as $group) { ?>
|
||||
<option value="<?php print $group['id']; ?>"<?php if($user['gid'] == $group['id']){ ?> selected="selected"<?php } ?>><?php print $group['groupname']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="domaincell"><?php print $text_search_groups; ?>*:</div>
|
||||
<div class="domaincell"><input type="text" id="s_piler_group" name="s_piler_group" value="<?php print $text_search_group_to_add; ?>" class="autocompletetext" onfocus="javascript:toggle_hint('s_piler_group', '<?php print $text_search_group_to_add; ?>', 1);" onblur="javascript:toggle_hint('s_piler_group', '<?php print $text_search_group_to_add; ?>', 0);" /></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_groups; ?>**:</div>
|
||||
<div class="domaincell"><textarea style="height:80px;" name="group" id="group" class="domain"><?php if(isset($user['group'])){ print $user['group']; } ?></textarea></div>
|
||||
</div>
|
||||
|
||||
<?php if(ENABLE_LDAP_IMPORT_FEATURE == 1) { ?>
|
||||
<div class="domainrow">
|
||||
@ -90,6 +87,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell">*: <?php print $text_min_2_chars; ?><br />**: <?php print $text_enter_one_group_per_line; ?></div>
|
||||
</div>
|
||||
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell"><input type="submit" value="<?php print $text_modify; ?>" /><input type="reset" value="<?php print $text_cancel; ?>" /></div>
|
||||
|
Loading…
Reference in New Issue
Block a user