added folder handling to webui

This commit is contained in:
SJ 2012-09-15 15:30:35 +02:00
parent b2fa1bf3b1
commit b03ca2effb
18 changed files with 340 additions and 19 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "0.1.21"
#define BUILD 704
#define BUILD 705
#define HOSTID "mailarchiver"

View File

@ -8,6 +8,7 @@ RewriteRule ^search-helper.php /index.php?route=search/helper [L]
RewriteRule ^audit-helper.php /index.php?route=audit/helper [L]
RewriteRule ^message.php /index.php?route=message/view [L]
RewriteRule ^bulkrestore.php /index.php?route=message/bulkrestore [L]
RewriteRule ^folders.php /index.php?route=folder/list& [QSA,L]
RewriteRule ^settings.php /index.php?route=user/settings [L]
RewriteRule ^login.php /index.php?route=login/login [L]
RewriteRule ^logout.php /index.php?route=login/logout [L]

View File

@ -0,0 +1,27 @@
<?php
class ControllerFolderCopy extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "search/save.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('folder/folder');
$this->model_folder_folder->copy_message_to_folder_by_id($this->request->post['folder_id'], $this->request->post['id']);
//$this->render();
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
class ControllerFolderList extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "folder/list.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('folder/folder');
$this->document->title = $this->data['text_folders'];
if(isset($this->request->post['name']) && $this->request->post['name']) {
$this->model_folder_folder->add_extra_folder($this->request->post['name']);
Header("Location: folders.php");
return;
}
if(isset($this->request->get['id']) && $this->request->get['id'] > 0) {
$this->model_folder_folder->remove_extra_folder($this->request->get['id']);
Header("Location: folders.php");
return;
}
/*if($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) {
if($this->model_user_auth->change_password(Registry::get('username'), $this->request->post['password']) == 1) {
$this->data['x'] = $this->data['text_password_changed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_change_password'];
}
}*/
$this->data['page_len'] = get_page_length();
$this->data['extra_folders'] = $this->model_folder_folder->get_extra_folders_for_user();
$this->render();
}
private function validate() {
if(!isset($this->request->post['password']) || !isset($this->request->post['password2']) ) {
$this->error['password'] = $this->data['text_missing_password'];
}
if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) {
$this->error['password'] = $this->data['text_invalid_password'];
}
if($this->request->post['password'] != $this->request->post['password2']) {
$this->error['password'] = $this->data['text_password_mismatch'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -14,6 +14,7 @@ class ControllerSearchFolder extends Controller {
$this->load->model('folder/folder');
$this->data['folders'] = $this->model_folder_folder->get_folders_for_user();
$this->data['extra_folders'] = $this->model_folder_folder->get_extra_folders_for_user();
$this->render();
}

View File

@ -17,6 +17,7 @@ class ControllerSearchHelper extends Controller {
'note' => '',
'ref' => '',
'folders' => '',
'extra_folders' => '',
'any' => ''
);
@ -94,6 +95,7 @@ class ControllerSearchHelper extends Controller {
private function fixup_post_request() {
if(isset($this->request->post['ref'])) { $this->a['ref'] = $this->request->post['ref']; }
if(isset($this->request->post['folders'])) { $this->a['folders'] = $this->request->post['folders']; }
if(isset($this->request->post['extra_folders'])) { $this->a['extra_folders'] = $this->request->post['extra_folders']; }
$this->a['sort'] = $this->request->post['sort'];
$this->a['order'] = $this->request->post['order'];

View File

@ -39,6 +39,7 @@ $_['text_compressed'] = "compressed";
$_['text_confirm_to_reset_counters'] = "Confirm to reset counters";
$_['text_content_filter'] = "Content filter";
$_['text_conversation_available'] = "Conversation available";
$_['text_copied'] = "Copied";
$_['text_counters'] = "Counters";
$_['text_cpu_load'] = "CPU load";
$_['text_cpu_usage'] = "CPU usage";
@ -94,6 +95,7 @@ $_['text_exact_domain_name_or_email_address'] = "exact domain name or email addr
$_['text_exclude'] = "Exclude";
$_['text_existing_domains'] = "Existing domains";
$_['text_existing_email'] = "Existing email";
$_['text_existing_folders'] = "Existing folders";
$_['text_existing_groups'] = "Existing groups";
$_['text_existing_policies'] = "Existing policies";
$_['text_existing_rules'] = "Existing rules";
@ -112,6 +114,7 @@ $_['text_failed_to_remove'] = "Failed to remove";
$_['text_failed_to_restore'] = "Failed to restore";
$_['text_failed_to_update'] = "Failed to update";
$_['text_first'] = "First";
$_['text_folder'] = "Folder";
$_['text_folders'] = "Folders";
$_['text_from'] = "From";
$_['text_from_domain'] = "From domain";

View File

@ -39,6 +39,7 @@ $_['text_compressed'] = "t
$_['text_confirm_to_reset_counters'] = "Számlálók nullázásának megerõsítése";
$_['text_content_filter'] = "Tartalomszûrõ";
$_['text_conversation_available'] = "Levélváltás elérhetõ";
$_['text_copied'] = "Átmásolva";
$_['text_counters'] = "Számlálók";
$_['text_cpu_load'] = "CPU terhelés";
$_['text_cpu_usage'] = "CPU használat";
@ -94,6 +95,7 @@ $_['text_exact_domain_name_or_email_address'] = "pontos domainn
$_['text_exclude'] = "Kihagy";
$_['text_existing_domains'] = "Létezõ domainek";
$_['text_existing_email'] = "Létezõ email";
$_['text_existing_groups'] = "Létezõ mappák";
$_['text_existing_groups'] = "Létezõ csoportok";
$_['text_existing_policies'] = "Létezõ házirendek";
$_['text_existing_rules'] = "Létezõ szabályok";
@ -112,6 +114,7 @@ $_['text_failed_to_remove'] = "Hiba az elt
$_['text_failed_to_restore'] = "Hiba a visszaállítás során";
$_['text_failed_to_update'] = "Nem sikerült módosítani";
$_['text_first'] = "Elsõ";
$_['text_folder'] = "Mappa";
$_['text_folders'] = "Mappák";
$_['text_from'] = "Feladó";
$_['text_from_domain'] = "Feladó domain";

View File

@ -39,6 +39,7 @@ $_['text_compressed'] = "tömörített";
$_['text_confirm_to_reset_counters'] = "Számlálók nullázásának megerősítése";
$_['text_content_filter'] = "Tartalomszűrő";
$_['text_conversation_available'] = "Levélváltás elérhető";
$_['text_copied'] = "Átmásolva";
$_['text_counters'] = "Számlálók";
$_['text_cpu_load'] = "CPU terhelés";
$_['text_cpu_usage'] = "CPU használat";
@ -94,6 +95,7 @@ $_['text_exact_domain_name_or_email_address'] = "pontos domainnév vagy email c
$_['text_exclude'] = "Kihagy";
$_['text_existing_domains'] = "Létező domainek";
$_['text_existing_email'] = "Létező email";
$_['text_existing_groups'] = "Létező mappák";
$_['text_existing_groups'] = "Létező csoportok";
$_['text_existing_policies'] = "Létező házirendek";
$_['text_existing_rules'] = "Létező szabályok";
@ -112,6 +114,7 @@ $_['text_failed_to_remove'] = "Hiba az eltávolításkor";
$_['text_failed_to_restore'] = "Hiba a visszaállítás során";
$_['text_failed_to_update'] = "Nem sikerült módosítani";
$_['text_first'] = "Első";
$_['text_folder'] = "Mappa";
$_['text_folders'] = "Mappák";
$_['text_from'] = "Feladó";
$_['text_from_domain'] = "Feladó domain";

View File

@ -54,6 +54,31 @@ class ModelFolderFolder extends Model {
}
public function get_extra_folders_for_user() {
$query = $this->db->query("SELECT `id`, `name` FROM `" . TABLE_FOLDER_EXTRA . "` WHERE uid=? ORDER BY name", array($_SESSION['uid']));
if(isset($query->rows)) { return $query->rows; }
return array();
}
private function is_your_extra_folder($folder_id = 0) {
$query = $this->db->query("SELECT `id` FROM `" . TABLE_FOLDER_EXTRA . "` WHERE uid=? AND id=?", array($_SESSION['uid'], $folder_id));
if(isset($query->row['id'])) { return 1; }
return 0;
}
public function copy_message_to_folder_by_id($folder_id = 0, $meta_id = 0) {
if(!$this->is_your_extra_folder($folder_id)) { return -1; }
$query = $this->db->query("INSERT INTO " . TABLE_FOLDER_MESSAGE . " (folder_id, id) VALUES(?,?)", array($folder_id, $meta_id));
return $this->db->countAffected();
}
public function get_all_folder_ids($uid = 0) {
$arr = array();
@ -70,6 +95,21 @@ class ModelFolderFolder extends Model {
}
public function get_all_extra_folder_ids($uid = 0) {
$arr = array();
$query = $this->db->query("SELECT id FROM `" . TABLE_FOLDER_EXTRA . "` WHERE uid=?", array($uid));
if(isset($query->rows)) {
foreach ($query->rows as $q) {
array_push($arr, $q['id']);
}
}
return $arr;
}
private function get_sub_folders($id = 0, &$arr = array()) {
$query = $this->db->query("SELECT id FROM `" . TABLE_FOLDER . "` WHERE parent_id=?", array($id));
@ -106,6 +146,27 @@ class ModelFolderFolder extends Model {
}
public function add_extra_folder($name = '') {
if($name == '') { return -1; }
$query = $this->db->query("INSERT INTO " . TABLE_FOLDER_EXTRA . " (uid, name) VALUES(?,?)", array($_SESSION['uid'], $name));
return $this->db->countAffected();
}
public function remove_extra_folder($id = 0) {
if($id == 0) { return -1; }
$query = $this->db->query("DELETE FROM " . TABLE_FOLDER_EXTRA . " WHERE id=? AND uid=?", array($id, $_SESSION['uid']));
if($this->db->countAffected() == 1) {
$query = $this->db->query("DELETE FROM " . TABLE_FOLDER_MESSAGE . " WHERE folder_id=?", array($id));
return $this->db->countAffected();
}
return 0;
}
}
?>

View File

@ -292,6 +292,10 @@ class ModelSearchSearch extends Model {
$id_list = $this->get_sphinx_id_list($data['note'], SPHINX_NOTE_INDEX, 'note');
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $folders id IN ($id_list) $sortorder LIMIT 0," . MAX_SEARCH_HITS);
}
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && isset($data['extra_folders']) && $data['extra_folders']) {
$ids_in_extra_folders = $this->get_sphinx_id_list_by_extra_folders($data['extra_folders']);
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $date $attachment $direction $size MATCH('$match') AND id IN ($ids_in_extra_folders) $sortorder LIMIT 0," . MAX_SEARCH_HITS);
}
else {
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $date $attachment $direction $size $folders MATCH('$match') $sortorder LIMIT 0," . MAX_SEARCH_HITS);
}
@ -388,6 +392,33 @@ class ModelSearchSearch extends Model {
}
private function get_sphinx_id_list_by_extra_folders($extra_folders = '') {
$id_list = '';
$q = '';
$__folders = array();
$s = explode(" ", $extra_folders);
while(list($k,$v) = each($s)) {
if(in_array($v, $_SESSION['extra_folders']) && is_numeric($v)) {
array_push($__folders, $v);
if($q) { $q .= ",?"; }
else { $q = "?"; }
}
}
$q = $this->db->query("SELECT id FROM " . TABLE_FOLDER_MESSAGE . " WHERE folder_id IN ($q)", $__folders);
foreach($q->rows as $a) {
$id_list .= "," . $a['id'];
}
if($id_list) { $id_list = substr($id_list, 1, strlen($id_list)); }
return $id_list;
}
private function get_meta_data($ids = array(), $q = '', $sortorder = '') {
$messages = array();
$tag = array();

View File

@ -21,6 +21,7 @@ class ModelUserAuth extends Model {
$_SESSION['emails'] = $this->model_user_user->get_users_all_email_addresses($query->row['uid']);
$_SESSION['folders'] = $this->model_folder_folder->get_all_folder_ids($query->row['uid']);
$_SESSION['extra_folders'] = $this->model_folder_folder->get_all_extra_folder_ids($query->row['uid']);
AUDIT(ACTION_LOGIN, $username, '', '', 'successful auth against user table');

View File

@ -197,6 +197,7 @@ function assemble_search_term(n, prefix) {
var attachment_type = '';
var e;
var folders = '';
var extra_folders = '';
e = document.getElementById(prefix + 'searchtype');
if(e && e.value) { data = data + "searchtype=" + e.value; }
@ -274,6 +275,11 @@ function assemble_search_term(n, prefix) {
if(b.name && b.name.substring(0, 7) == 'folder_' && b.checked) {
folders = folders + "+" + b.name.substring(7);
}
if(b.name && b.name.substring(0, 13) == 'extra_folder_' && b.checked) {
extra_folders = extra_folders + "+" + b.name.substring(13);
}
}
}
@ -282,6 +288,10 @@ function assemble_search_term(n, prefix) {
data = data + "&folders=" + folders;
}
if(extra_folders) {
extra_folders = extra_folders.substring(1);
data = data + "&extra_folders=" + extra_folders;
}
//alert("data: " + data);
@ -709,13 +719,37 @@ function show_message(id, msg, timeout){
}
function move_message_list_scrollbar(direction) {
var current_result_div = document.getElementById('e_' + current_messages[current_message_serial]);
if(current_result_div){
if(current_message_serial % 2) current_result_div.className = 'resultrow odd';
else current_result_div.className = 'resultrow';
function set_scroll_position(current_message_serial) {
var objDiv = document.getElementById("messagelistcontainer");
if(objDiv) {
objDiv.scrollTop = current_message_serial*17 - 30;
}
}
function highlight_message_by_position(pos) {
var a;
for(i=1; i<=current_messages.length; i++) {
a = document.getElementById('e_' + current_messages[i]);
if(a) {
if(i % 2) a.className = 'resultrow odd';
else a.className = 'resultrow';
}
}
load_url_with_get(message_loader_url + current_messages[pos], 'mailpreviewframe');
a = document.getElementById('e_' + current_messages[pos]);
if(a){ a.className = 'resultrow selected'; }
set_scroll_position(pos);
}
function move_message_list_scrollbar(direction) {
if(direction == 'down') {
if(current_message_serial < current_messages.length-1) current_message_serial++;
@ -724,14 +758,21 @@ function move_message_list_scrollbar(direction) {
if(current_message_serial > 1) current_message_serial--;
}
load_url_with_get(message_loader_url + current_messages[current_message_serial], 'mailpreviewframe');
current_result_div = document.getElementById('e_' + current_messages[current_message_serial]);
if(current_result_div){ current_result_div.className = 'resultrow selected'; }
var objDiv = document.getElementById("messagelistcontainer");
if(objDiv) objDiv.scrollTop = current_message_serial*17 - 30;
highlight_message_by_position(current_message_serial);
}
function copy_message_to_folder(folder_id, id, copied) {
if(id <= 0) { return 0; }
params = "folder_id=" + folder_id + "&id=" + id;
send_ajax_post_request(folder_copy_url, params);
show_message('messagebox1', '<p>' + copied + '</p>', 0.85);
current_message_id = 0;
}

View File

@ -21,10 +21,12 @@
<script type="text/javascript" src="/view/javascript/jquery.dropdownPlain.js"></script>
<script type="text/javascript">
var current_message_id = 0;
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&';
var folder_search_url = '<?php print SITE_URL; ?>/index.php?route=folder/folder&';
var folder_copy_url = '<?php print SITE_URL; ?>/index.php?route=folder/copy';
var message_loader_url = '<?php print SITE_URL; ?>message.php/';
</script>
@ -116,6 +118,7 @@
<?php print $folder; ?>
</div>
<script type="text/javascript">
var mailviewsplitv = new rcube_splitter({id:'splitter1', p1: 'mailleftcontainer', p2: 'mailrightcontainer', orientation: 'v', relative: true, start: 165});
split.add_onload('mailviewsplitv.init()');
@ -140,7 +143,7 @@
split.add_onload('mailviewsplit.init()');
</script>
<div id="mailpreviewframe" style="text-align: left; overflow:auto;">
<div id="mailpreviewframe" onmouseover="javascript: current_message_id = 0;" style="text-align: left; overflow:auto;">
</div>

View File

@ -2,6 +2,9 @@
<div class="logout22">
<a href="search.php"<?php if($_SERVER['REQUEST_URI'] == '/' || strstr($_SERVER['REQUEST_URI'], "search.php")){ ?> id="active"<?php } ?>><?php print $text_search; ?></a> |
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
<a href="/folders.php"<?php if(strstr($_SERVER['REQUEST_URI'], "folders.php")){ ?> id="active"<?php } ?>><?php print $text_folders; ?></a> |
<?php } ?>
<a href="/settings.php"<?php if(strstr($_SERVER['REQUEST_URI'], "settings.php")){ ?> id="active"<?php } ?>><?php print $text_settings; ?></a> |
<?php if(isset($_SESSION['realname'])) { print $text_realname; ?>: <?php print $_SESSION['realname']; ?> | <?php } ?>
<a href="/logout.php"<?php if(strstr($_SERVER['QUERY_STRING'], "login/logout")){ ?> id="active"<?php } ?>><?php print $text_logout; ?></a>

View File

@ -0,0 +1,54 @@
<?php if(!isset($x)){ ?>
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
<form action="/folders.php" method="post" name="extra_folders">
<div id="search">
<div id="search1">
<div class="row">
<div class="cell1"><?php print $text_folder; ?></div>
<div class="cell2"><input type="text" id="name" name="name" value="" /></div>
</div>
<div class="row">
<div class="cell1">&nbsp;</div>
<div class="cell2"><input type="submit" value="<?php print $text_add; ?>" /> <input type="reset" value="<?php print $text_cancel; ?>" /></div>
</div>
</div>
</div>
</form>
<div id="search">
<h4><?php print $text_existing_folders; ?></h4>
<div id="search1">
<?php foreach($extra_folders as $folder) { ?>
<div class="row">
<div class="cell1"><?php print $folder['name']; ?></div>
<div class="cell2"><a href="/folders.php?id=<?php print $folder['id']; ?>&remove=1"><?php print $text_remove; ?></a></div>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php } else { ?>
<?php print $x; ?>. <a href="index.php?route=common/home"><?php print $text_back; ?></a>
<?php } ?>

View File

@ -4,9 +4,14 @@
<?php foreach ($folders as $folder) { ?>
<input type="checkbox" id="folder_<?php print $folder['id']; ?>" name="folder_<?php print $folder['id']; ?>" /> <?php print $folder['name']; ?><br />
<?php } ?>
<?php foreach ($extra_folders as $folder) { ?>
<input type="checkbox" id="extra_folder_<?php print $folder['id']; ?>" name="extra_folder_<?php print $folder['id']; ?>" /> <span style="color: blue; font-weight: bold;" onmouseover="javascript: copy_message_to_folder('<?php print $folder['id']; ?>', current_message_id, '<?php print $text_copied; ?>'); return false;"><?php print $folder['name']; ?></span><br />
<?php } ?>
</div>

View File

@ -44,10 +44,10 @@
<div id="e_<?php print $message['id']; ?>" class="resultrow<?php if($i % 2) { ?> odd<?php } ?><?php if($message['spam'] == 1) { ?> spam<?php } ?>">
<div class="cell5 restore"><input type="checkbox" id="r_<?php print $message['id']; ?>" name="r_<?php print $message['id']; ?>" value="iiii" checked="checked" class="restorebox" /></div>
<div class="cell5 id"><a href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>message.php/<?php print $message['id']; ?>', 'mailpreviewframe'); current_message_serial = <?php print $i; ?>; return false;"><?php print ($page*$page_len) + $i; ?>.</a></div>
<div class="cell5 id"><a href="#" onmouseover="javascript: current_message_id = <?php print $message['id']; ?>; return false;" onclick="script:highlight_message_by_position(<?php print $i; ?>); current_message_id = <?php print $message['id']; ?>; return false;"><?php print ($page*$page_len) + $i; ?>.</a></div>
<div class="cell5 date"><?php print $message['date']; ?></div>
<div class="cell5 from"><?php if($message['from'] != $message['shortfrom']) { ?><a href="#" title="<?php print preg_replace("/&/", "&amp;", $message['from']); ?>"><?php print $message['shortfrom']; ?></a><?php } else { print $message['from']; } ?></div>
<div class="cell5 subject"><a href="#" <?php if($message['subject'] != $message['shortsubject']) { ?>title="<?php print preg_replace("/&/", "&amp;", $message['subject']); ?>"<?php } ?> onclick="script:load_url_with_get('<?php print SITE_URL; ?>message.php/<?php print $message['id']; ?>', 'mailpreviewframe'); current_message_serial = <?php print $i; ?>; return false;"><?php if($message['subject'] != $message['shortsubject']) { print $message['shortsubject']; } else { print $message['subject']; } ?></a><?php if($message['reference']) { ?> <a href="#" title="<?php print $text_conversation_available; ?>" onclick="script:add_message_reference_to_form('<?php print $message['reference']; ?>'); load_search_results('<?php print SEARCH_HELPER_URL; ?>', assemble_search_term(count, ''), 0); a = document.getElementById('ref'); a.value=''; return false;">[+]</span></a><?php } ?></div>
<div class="cell5 subject"><a href="#" <?php if($message['subject'] != $message['shortsubject']) { ?>title="<?php print preg_replace("/&/", "&amp;", $message['subject']); ?>"<?php } ?> onmouseover="javascript: current_message_id = <?php print $message['id']; ?>; return false;" onclick="script:highlight_message_by_position(<?php print $i; ?>); current_message_id = <?php print $message['id']; ?>; return false;"><?php if($message['subject'] != $message['shortsubject']) { print $message['shortsubject']; } else { print $message['subject']; } ?></a><?php if($message['reference']) { ?> <a href="#" title="<?php print $text_conversation_available; ?>" onclick="script:add_message_reference_to_form('<?php print $message['reference']; ?>'); load_search_results('<?php print SEARCH_HELPER_URL; ?>', assemble_search_term(count, ''), 0); a = document.getElementById('ref'); a.value=''; return false;">[+]</span></a><?php } ?></div>
<div class="cell5 size"><?php print $message['size']; ?></div>
<div class="cell5"><?php if($message['attachments'] > 0) { ?><img src="<?php print ICON_ATTACHMENT; ?>" alt="" width="16" height="18" /><?php } else { ?>&nbsp;<?php } ?></div>