diff --git a/src/pilerexport.c b/src/pilerexport.c index 526595f5..c0f15744 100644 --- a/src/pilerexport.c +++ b/src/pilerexport.c @@ -311,6 +311,8 @@ int main(int argc, char **argv){ regfree(®exp); + (void) openlog("pilerexport", LOG_PID, LOG_MAIL); + snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE ", SQL_MESSAGES_VIEW); diff --git a/src/pilerimport.c b/src/pilerimport.c index 0af1aff6..24d88ced 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -214,6 +214,7 @@ int main(int argc, char **argv){ if(!mailbox && !emlfile && !directory) usage(); + (void) openlog("pilerimport", LOG_PID, LOG_MAIL); cfg = read_config(configfile); diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 80b53e10..fb82a834 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -94,6 +94,10 @@ create table if not exists `attachment` ( create index `attachment_idx` on `attachment`(`piler_id`); create index `attachment_idx2` on `attachment`(`sig`); +create index `attachment_idx3` on `attachment`(`ptr`); + +drop view if exists `v_attachment`; +create view `v_attachment` AS select `id` as `i`, `piler_id`, `attachment_id`, `ptr`, (select count(*) from `attachment` where `ptr`=`i`) as `refcount` from `attachment`; drop table if exists `tag`; diff --git a/webui/config.php b/webui/config.php index 8d837891..c9ecc969 100644 --- a/webui/config.php +++ b/webui/config.php @@ -129,6 +129,7 @@ define('SEARCH_HELPER_URL', SITE_URL . 'search-helper.php'); define('AUDIT_HELPER_URL', SITE_URL . 'audit-helper.php'); define('SAVE_SEARCH_URL', SITE_URL . 'index.php?route=search/save'); +define('SEARCH_TAG_URL', SITE_URL . 'index.php?route=search/tag'); define('HEALTH_WORKER_URL', SITE_URL . 'index.php?route=health/worker'); define('HEALTH_REFRESH', 60); diff --git a/webui/controller/search/helper.php b/webui/controller/search/helper.php index 59901bc7..83f840a4 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -53,7 +53,7 @@ class ControllerSearchHelper extends Controller { $this->preprocess_post_advanced_request($this->request->post); $this->fixup_post_request(); - list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); + list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); } else if($this->request->post['searchtype'] == 'expert'){ @@ -61,14 +61,15 @@ class ControllerSearchHelper extends Controller { $this->preprocess_post_expert_request($this->request->post); $this->fixup_post_request(); - list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); + list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); } else { $this->fixup_post_simple_request(); - list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']); + list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']); } + if($this->a['ref']) { $this->data['_ref'] = $this->a['ref']; } /* paging info */ diff --git a/webui/controller/search/tag.php b/webui/controller/search/tag.php new file mode 100644 index 00000000..3d162b31 --- /dev/null +++ b/webui/controller/search/tag.php @@ -0,0 +1,42 @@ +id = "content"; + $this->template = "search/tag.tpl"; + $this->layout = "common/layout-empty"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('search/search'); + $this->load->model('search/message'); + + if(isset($this->request->post['tag']) && isset($this->request->post['idlist'])) { + $idlist = explode(",", $this->request->post['idlist']); + if(count($idlist) > 0) { + + $q = ''; + + $ids = $this->model_search_search->check_your_permission_by_id_list($idlist); + + for($i=0; $imodel_search_message->bulk_add_message_tag($ids, $_SESSION['uid'], $this->request->post['tag'], $q); + } + } + + /*$this->data['message'] = 'I tagged this!'; + + $this->render();*/ + } + +} + +?> diff --git a/webui/model/search/message.php b/webui/model/search/message.php index 7dc47038..fc3dc390 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -415,6 +415,18 @@ class ModelSearchMessage extends Model { } + public function bulk_add_message_tag($ids = array(), $uid = 0, $tag = '', $q = '') { + $arr = array_merge(array($uid), $ids); + + $query = $this->db->query("DELETE FROM " . TABLE_TAG . " WHERE uid=? AND id IN ($q)", $arr); + + if($tag) { + foreach ($ids as $id) { + $query = $this->db->query("INSERT INTO " . TABLE_TAG . " (id, uid, tag) VALUES(?,?,?)", array($id, $uid, $tag)); + } + } + } + } ?> diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 3e422beb..edb89451 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -11,6 +11,7 @@ class ModelSearchSearch extends Model { $cache_key = ""; $q = ""; $s = ""; + $all_ids_csv = ""; while(list($k,$v) = each($data)) { if($v) { $s .= '&' . $k . '=' . $v; } @@ -61,6 +62,7 @@ class ModelSearchSearch extends Model { $total_hits = count($all_ids); + $all_ids_csv = implode(",", $all_ids); $data['page_len'] = get_page_length(); @@ -71,6 +73,7 @@ class ModelSearchSearch extends Model { if($i >= $data['page_len'] * $page && $i < $data['page_len'] * ($page+1) ) { array_push($one_page_of_ids, $id); + $all_ids_csv .= ",$id"; if($q) { $q .= ",?"; } else { $q = "?"; } } @@ -80,7 +83,7 @@ class ModelSearchSearch extends Model { } - return array($total_hits, $this->get_meta_data($one_page_of_ids, $q, $sortorder)); + return array($total_hits, $all_ids_csv, $this->get_meta_data($one_page_of_ids, $q, $sortorder)); } @@ -451,6 +454,46 @@ class ModelSearchSearch extends Model { } + public function check_your_permission_by_id_list($id = array()) { + $q = $q2 = ''; + $arr = $a = $result = array(); + + if($id == '') { return 0; } + + if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) { return 1; } + + $arr = $id; + + for($i=0; $idb->query("SELECT distinct id FROM " . VIEW_MESSAGES . " WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) )", $arr); + + if($query->num_rows > 0) { + foreach ($query->rows as $q) { + array_push($result, $q['id']); + } + } + + return $result; + } + + public function remove_message($id = '') { if($id == '') { return 0; } diff --git a/webui/view/javascript/piler.js b/webui/view/javascript/piler.js index 303a2793..ac56e9e4 100644 --- a/webui/view/javascript/piler.js +++ b/webui/view/javascript/piler.js @@ -355,6 +355,37 @@ function removeme(id) { } +function tag_search_results(url){ + var idlist = ''; + + var tag_keys = document.getElementById('tag_keys').value; + var tag_value = document.getElementById('tag_value').value; + + if(tag_keys) { + params = "idlist=" + tag_keys + "&tag=" + encodeURI(tag_value); + + var http = getXMLHttp(); + + if(http == null) { alert("Error creating XMLHttpRequest"); return; } + + http.onreadystatechange = function() { + if(http.readyState == 4) { + if(http.status != 200) alert("Problem retrieving XML data:" + http.statusText); + } + } + + http.open("POST", url, true); + + http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + http.setRequestHeader("Content-length", params.length); + http.setRequestHeader("Connection", "close"); + + http.send(params); + } +} + + + $(document).ready(function() { $.datepicker.setDefaults($.datepicker.regional[piler_ui_lang]); $("#date1").datepicker( { dateFormat: 'yy-mm-dd' } ); diff --git a/webui/view/theme/default/stylesheet/style-default.css b/webui/view/theme/default/stylesheet/style-default.css index bd1249e7..4bb4198e 100644 --- a/webui/view/theme/default/stylesheet/style-default.css +++ b/webui/view/theme/default/stylesheet/style-default.css @@ -64,6 +64,7 @@ .text { font: normal 12px Arial, sans-serif; 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: 280px; } .advtextgrey { font: bold 12px Arial, sans-serif; color: #999; font-weight: bold; text-align:left; width: 280px; } .textregular { font: normal 12px Arial, sans-serif; font-weight: bold; text-align:left; } @@ -108,13 +109,14 @@ #health1 .error { color: red; font-weight: bold; } #pagenav { float: left; margin-top: 0px; margin-bottom: 0px; text-align: left; width: 990px; border: 0px solid red; } - .navrow { display: table-row; width: 282px; border: 1px solid red; } + .navrow { display: table-row; } .navlink { color: #bbb; font: bold 12px Arial, sans-serif; } #pagenav a.navlink { color: #850505; font: bold 12px Arial, sans-serif; } #pagingleft { display: table-cell; float: left; text-align: left; width: 60px; border: 0px solid red; } #pagingcenter { display: table-cell; float: left; text-align: center; width: 145px; border: 0px solid red; } - #pagingright { display: table-cell; float: right; text-align: right; width: 60px; border: 0px solid red; } + #pagingright { display: table-cell; float: left; text-align: right; width: 60px; border: 0px solid red; } + #tagbox { display: table-cell; float: left; text-align: right; vertical-align: top; width: 725px; border: 0px solid red; } .messagelink { border-bottom: 1px solid gray; color: #850505; } .messagelink.spam { border-bottom: 1px solid gray; color: #aaa; } @@ -125,7 +127,6 @@ .advselect2 { width: 205px; font: bold 12px Arial, sans-serif; padding: 0; margin:0;} .ruleselect { width: 40px; font: bold 12px Arial, sans-serif; padding: 0; margin:0;} - /*button { margin-left: 0px; background-color:gray; border-top:1px solid gray; border-left:1px solid gray; font: bold 12px Arial, sans-serif; border-left: yellow; border-right: black; width:50%;}*/ button { margin: 0; background-color:gray; font: bold 12px Arial, sans-serif; width:40%; height: 40px; margin-left: 5%; margin-right: 5%; } button.active { background-color: #850505; color:white; } @@ -136,6 +137,8 @@ input[type=button].load { margin: 0; background-color:#eee; color: black; font: bold 12px Arial, sans-serif; width: 17%;} input[type=button].short { margin: 0; background-color:#eee; color: gray; font: bold 12px Arial, sans-serif; width: 50px;} + input[type=button].tag { margin: 0; background-color:#eee; color: gray; font: normal 10px Arial, sans-serif; } + input[type=checkbox].attachmenttype { margin: 0; vertical-align: middle; } #messagepopup { margin: 10px 20px 10px 20px; padding: 0; background-color: white; text-align: left; } @@ -158,8 +161,8 @@ ul.dropdown { position: relative; } ul.dropdown li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding-right: 40px; padding-left: 40px; border: 0px solid red; } ul.dropdown li.first_li { font-weight: bold; float: left; background: #ffffff; text-align: left; padding-left:80px; padding-right: 5px; } - ul.dropdown li.search_li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding: 0; padding-right: 5px; } - ul.dropdown li.no_search_li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding: 0; padding-right: 5px; } + ul.dropdown li.search_li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding: 0; padding-right: 0px; } + ul.dropdown li.no_search_li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding: 0; padding-right: 0px; } ul.dropdown li.center_li { font-weight: bold; float: left; background: #ffffff; text-align: center; padding: 0; width: 190px; } ul.dropdown li.last_li { font-weight: bold; float: left; background: #ffffff; text-align: right; padding: 0; } diff --git a/webui/view/theme/default/templates/common/menu.tpl b/webui/view/theme/default/templates/common/menu.tpl index f0d449e4..432f9432 100644 --- a/webui/view/theme/default/templates/common/menu.tpl +++ b/webui/view/theme/default/templates/common/menu.tpl @@ -10,7 +10,7 @@ diff --git a/webui/view/theme/default/templates/search/helper.tpl b/webui/view/theme/default/templates/search/helper.tpl index a90a6fd2..da7b016f 100644 --- a/webui/view/theme/default/templates/search/helper.tpl +++ b/webui/view/theme/default/templates/search/helper.tpl @@ -15,14 +15,20 @@ > >   >>   >> + 0){ ?> +
style="margin-left: 265px;"> + + + + Tag search results: +
  + - -
class="empty">
@@ -65,14 +71,14 @@ -
+
.
-
', BALLOON, true, ABOVE, true)" onmouseout="UnTip()">
- +
', BALLOON, true, ABOVE, true)" onmouseout="UnTip();">
+
0) { ?> 
-
 
+
 
verification status
diff --git a/webui/view/theme/default/templates/search/tag.tpl b/webui/view/theme/default/templates/search/tag.tpl new file mode 100644 index 00000000..f68cb846 --- /dev/null +++ b/webui/view/theme/default/templates/search/tag.tpl @@ -0,0 +1 @@ +