diff --git a/util/db-mysql.sql b/util/db-mysql.sql index a6618d2..94f4c24 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -189,7 +189,6 @@ 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 @@ `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 @@ ) 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, diff --git a/util/db-upgrade-0.18-vs-0.19.sql b/util/db-upgrade-0.18-vs-0.19.sql index b2c7372..429c393 100644 --- a/util/db-upgrade-0.18-vs-0.19.sql +++ b/util/db-upgrade-0.18-vs-0.19.sql @@ -10,6 +10,12 @@ 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; + diff --git a/webui/config.php b/webui/config.php index 5834b62..ae72a3a 100644 --- a/webui/config.php +++ b/webui/config.php @@ -81,6 +81,7 @@ 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'); diff --git a/webui/controller/group/add.php b/webui/controller/group/add.php index 837d0d5..ab61d7e 100644 --- a/webui/controller/group/add.php +++ b/webui/controller/group/add.php @@ -26,6 +26,8 @@ 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); diff --git a/webui/controller/group/edit.php b/webui/controller/group/edit.php index f69f6a3..dbcbb4f 100644 --- a/webui/controller/group/edit.php +++ b/webui/controller/group/edit.php @@ -38,8 +38,6 @@ 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 @@ } } 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']); } } diff --git a/webui/controller/group/email.php b/webui/controller/group/email.php new file mode 100644 index 0000000..f19c316 --- /dev/null +++ b/webui/controller/group/email.php @@ -0,0 +1,48 @@ +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; + } + } + + +} + +?> diff --git a/webui/controller/group/group.php b/webui/controller/group/group.php new file mode 100644 index 0000000..013c378 --- /dev/null +++ b/webui/controller/group/group.php @@ -0,0 +1,48 @@ +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; + } + } + + +} + +?> diff --git a/webui/controller/health/health.php b/webui/controller/health/health.php index b25782f..41063c9 100644 --- a/webui/controller/health/health.php +++ b/webui/controller/health/health.php @@ -19,7 +19,7 @@ /* 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']; } diff --git a/webui/controller/user/edit.php b/webui/controller/user/edit.php index 6d56928..633a82e 100644 --- a/webui/controller/user/edit.php +++ b/webui/controller/user/edit.php @@ -71,9 +71,9 @@ } 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']); diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 763ff04..2081d50 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -86,6 +86,7 @@ $_['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_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_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"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index 02fb33e..3ec3e62 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -86,6 +86,7 @@ $_['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_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_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"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index d20798a..dba388b 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -86,6 +86,7 @@ $_['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_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_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"; diff --git a/webui/model/group/group.php b/webui/model/group/group.php index 5f1ee15..45e4fbb 100644 --- a/webui/model/group/group.php +++ b/webui/model/group/group.php @@ -140,6 +140,41 @@ } + 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); + } + + } ?> diff --git a/webui/model/search/message.php b/webui/model/search/message.php index fc3dc39..d515d6e 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -57,8 +57,6 @@ 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 @@ $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 @@ 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 @@ $chunk = preg_replace("/", "<", $chunk); $chunk = preg_replace("/>/", ">", $chunk); - //$chunk = "
\n" . $this->print_nicely($chunk) . "\n"; $chunk = preg_replace("/\n/", "
diff --git a/webui/view/theme/default/templates/user/add.tpl b/webui/view/theme/default/templates/user/add.tpl index fa2bfa1..70541bd 100644 --- a/webui/view/theme/default/templates/user/add.tpl +++ b/webui/view/theme/default/templates/user/add.tpl @@ -32,17 +32,14 @@