webmail_controller moded from components to app
This commit is contained in:
parent
789f813b42
commit
ab8bf72949
22 changed files with 6 additions and 5 deletions
|
@ -1,5 +0,0 @@
|
|||
<ul class="contacts">
|
||||
<% for contact in @contacts do -%>
|
||||
<li class="contact"><%=h contact.fname %> <%= h contact.lname %> <div class='email'><div class="notviscode">&lt;</div><%= h contact.email %><div class="notviscode">&gt;</div></div></li>
|
||||
<% end -%>
|
||||
</ul>
|
|
@ -1,18 +0,0 @@
|
|||
<% @expression = @expressions[expr_counter] %>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="expression[<%=expr_counter%>][field_name]">
|
||||
<%= options_for_select(CDF::CONFIG[:mail_filters_fields], @expressions[expr_counter].field_name)%>
|
||||
</select></td>
|
||||
<td>
|
||||
<select name="expression[<%=expr_counter%>][operator]">
|
||||
<%= options_for_select(CDF::CONFIG[:mail_filters_expressions], @expressions[expr_counter].operator)%>
|
||||
</select></td>
|
||||
<td>
|
||||
<%= text_field 'expression', 'expr_value', 'index'=>expr_counter %>
|
||||
</td>
|
||||
<td>
|
||||
<%= hidden_field "expression", 'case_sensitive', 'index'=>expr_counter %>
|
||||
<%= check_box "expression", 'case_sensitive', {'onclick'=>'toggleCheckbox(this)', "index"=>expr_counter } %> <%= _('case sensitive') %>
|
||||
</td>
|
||||
</tr>
|
|
@ -1,19 +0,0 @@
|
|||
<tr>
|
||||
<td><%=h @user.filters[filter_counter].name%></th>
|
||||
<td>
|
||||
<% if filter_counter > 0 %>
|
||||
<%=link_filter_up(@user.filters[filter_counter].id)%>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if filter_counter < @user.filters.size - 1 %>
|
||||
<%=link_filter_down(@user.filters[filter_counter].id)%>
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%=link_filter_edit(@user.filters[filter_counter].id)%></td>
|
||||
<td><%=link_filter_delete(@user.filters[filter_counter].id)%></td>
|
||||
</tr>
|
|
@ -1,14 +0,0 @@
|
|||
<tr class="<%= message_row.unread ? 'notseen': 'seen' %>">
|
||||
<td class="mark"><input type="checkbox" name="messages[<%= message_row.uid %>]"/></td>
|
||||
<% if @folder_name == CDF::CONFIG[:mail_sent] %>
|
||||
<td class="to"><%= short_address(message_row.to_addr) %></td>
|
||||
<% else %>
|
||||
<td class="from"><%= short_address(message_row.from_addr) %></td>
|
||||
<% end %>
|
||||
<td class="subject"><div class='cutField'>
|
||||
<%= link_to(parse_subject(message_row.subject) << " " , :controller=>'webmail', :action=>'message', :msg_id=>message_row.uid)%>
|
||||
</td>
|
||||
<td class="date"><%= message_date(message_row.date) %></td>
|
||||
<td class="size"><%= message_size(message_row.size) %></td>
|
||||
<td class="attachind"><%= message_row.content_type == 'multipart' ? image_tag('attachment.png') : ' ' %></td>
|
||||
</tr>
|
|
@ -1,13 +0,0 @@
|
|||
<a href='#' onclick='toggle_msg_search(true);'>
|
||||
<%=_('Search')%><img id='img_msg_search' alt='open' src='/images/list_<%=@srch_img_src%>.gif'/>
|
||||
</a>
|
||||
<div id="msg_search" class='<%=@srch_class%>'>
|
||||
<%=_('Search in message field')%>
|
||||
<select name="search_field">
|
||||
<%= options_for_select(CDF::CONFIG[:mail_search_fields], @search_field)%>
|
||||
</select>
|
||||
<label for="search_value"><%=_('for')%></label>
|
||||
<input type="text" name="search_value" value="<%=@search_value%>" size='16' id='search_value'/>
|
||||
<%= submit_tag(_('Search'), :name=>'op')%>
|
||||
<%= submit_tag(_('Show all'), :name=>'op')%>
|
||||
</div>
|
|
@ -1,67 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<form name="composeMail" id='composeMail' action="/webmail/webmail/compose" enctype="multipart/form-data" method="post">
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><%=link_folders%></li>
|
||||
<li><span><%= _('Compose') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_compose_new%></li>
|
||||
<li><a href='#' onclick="getFormField('composeMail').submit();"><%=_('Send')%></a></li>
|
||||
<li><a href="#" onclick="chooseContacts();"><%= _('Choose addresses from contacts') %></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<div id="msg-compose">
|
||||
<input type="hidden" id="mail_toc" name="mail[toc]" value="<%=@mail.toc%>"/>
|
||||
<input type="hidden" id="mail_op" name="op" value="<%=_('Send')%>"/>
|
||||
<div id="msghdr">
|
||||
<table>
|
||||
<tr><td><label for=''><%=_('To')%></label></td><td><%= text_field_with_auto_complete(:mail, :to, {"size"=>65}, :skip_style => true, :tokens=> ",") %></td></tr>
|
||||
<tr><td><label for=''><%=_('CC')%></label></td><td><%= text_field_with_auto_complete(:mail, :cc, {"size"=>65}, :skip_style => true, :tokens=> ",") %></td></tr>
|
||||
<tr><td><label for=''><%=_('BCC')%></label></td><td><%= text_field_with_auto_complete(:mail, :bcc, {"size"=>65}, :skip_style => true, :tokens=> ",") %></td></tr>
|
||||
<tr><td><label for=''><%=_('Subject')%></label></td><td><%= text_field('mail', 'subject', {"size"=>65}) %></td></tr>
|
||||
</table>
|
||||
<%= hidden_field('mail', 'from') %>
|
||||
<%= hidden_field('mail', 'content_type') %>
|
||||
</div>
|
||||
|
||||
<div class="msgpart ct-text-plain">
|
||||
<%= text_area "mail", "body", "rows"=>20, "cols"=>75 %>
|
||||
</div>
|
||||
|
||||
<div class="msgpart">
|
||||
<% if @mail.attachments and @mail.attachments.size > 0%>
|
||||
<table class="attachments">
|
||||
<% i = 0
|
||||
@mail.attachments.each { |att| %>
|
||||
<tr><td><%=attachment(att, i)%></td></tr>
|
||||
<% i = i + 1
|
||||
}%>
|
||||
</table>
|
||||
<% end %>
|
||||
<hr/>
|
||||
<label for="attachment"><%=_('Attachment')%>:</label><%=%><input type="file" name="attachment"/>
|
||||
<input type="button" name="mail_add_attachement" value="<%=_('Add')%>"
|
||||
onclick="getFormField('mail_op').value='<%=_('Add')%>';getFormField('composeMail').submit();">
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
</form>
|
||||
|
||||
<% content_for("scripts") { %>
|
||||
<%= @additional_scripts %>
|
||||
<% if ['text/html', 'multipart'].include?(@mail.content_type) %>
|
||||
<%= include_tinymce %>
|
||||
<% end %>
|
||||
<%= javascript_include_tag "controls" %>
|
||||
<%= javascript_include_tag "dragdrop" %>
|
||||
<%= javascript_include_tag "effects" %>
|
||||
<% %>
|
||||
<% } %>
|
|
@ -1,28 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><span><%= _('Folders') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_refresh%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<% content_for('sidebar') { %>
|
||||
<div id="folders">
|
||||
<h4><%=_('Folders')%><br/><%=link_manage_folders%></h4>
|
||||
<hr/>
|
||||
<%=_('Error occured obtaining connection to mail server. Please excuse us!')%>
|
||||
</div>
|
||||
<% } %>
|
||||
<div id="messages">
|
||||
</div>
|
||||
|
||||
</div></div>
|
|
@ -1,41 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><%=link_folders%></li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><span><%= _('Filters') %></span></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<div id="filters">
|
||||
<form action="/webmail/webmail/filter" method="post">
|
||||
<%=hidden_field 'filter', 'id' %>
|
||||
<table class="list" width='100%'>
|
||||
<tr>
|
||||
<td><label for="filter[name]"><%=_('Filter name')%></label></td>
|
||||
<td colspan='3'><%=text_field 'filter', 'name' %></td>
|
||||
</tr>
|
||||
<tr><td colspan="4"><%=_('Messages matching')%></td></tr>
|
||||
<%= render_partial_collection "expr", @expressions %>
|
||||
<tr><td colspan="4"><input type="submit" name="op" value="<%=_('Add')%>"/></td></tr>
|
||||
<tr>
|
||||
<td><label for="filter[destination_folder]"><%=_('Will be placed in')%></label></td>
|
||||
<td colspan='3'>
|
||||
<select name="filter[destination_folder]">
|
||||
<%= options_from_collection_for_select(@destfolders, 'name', 'name', @filter.destination_folder) %>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan="4">
|
||||
<input type="submit" name="op" value="<%=_('Save')%>"/>
|
||||
<input type="button" name="op" value="<%=_('Cancel')%>" onclick="changeLoc('/webmail/webmail/filters');"/>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div></div>
|
|
@ -1,39 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><%=link_folders%></li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><span><%= _('Filters') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_filter_add%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<div id="filters">
|
||||
<form action="/webmail/webmail/filters" method="post">
|
||||
<% if @user.filters and @user.filters.size > 0 %>
|
||||
<table class="list">
|
||||
<tr>
|
||||
<th><%=_('Filter name')%></th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<%= render_partial_collection "filter", @user.filters %>
|
||||
</table>
|
||||
<% end %>
|
||||
</form>
|
||||
<% if @flash['error'] %>
|
||||
<div id="SystemError"><%= @flash['error'] %></div>
|
||||
<% elsif @flash['status'] %>
|
||||
<div id="SystemStatus"><%= @flash['status'] %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div></div>
|
|
@ -1,35 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><span><%= _('Folders') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_refresh%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<% content_for('sidebar') { %>
|
||||
<div id="folders">
|
||||
<h4><%=_('Folders')%><br/><%=link_manage_folders%></h4>
|
||||
<hr/>
|
||||
<ul> <% for folder in @folders %>
|
||||
<li><%=folder_link(folder)%></li> <% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% } %>
|
||||
<div id="messages">
|
||||
<% if not(@request['msg_id'] == '') %>
|
||||
<%= render_component(:controller => "webmail/webmail", :action => "message", :params => { 'msg_id' => @request['msg_id']})%>
|
||||
<% else %>
|
||||
<%= render_component(:controller => "webmail/webmail", :action => "messages") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div></div>
|
|
@ -1,31 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><%=link_folders%></li>
|
||||
<li><span><%= _('Compose') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_compose_new%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<div class="msghdr">
|
||||
<dl>
|
||||
<dt><%=_('To')%></dt><dd><%= CGI.escapeHTML(@mail.to) %></dd>
|
||||
<% if @mail.cc %>
|
||||
<dt><%=_('CC')%></dt><dd><%= CGI.escapeHTML(@mail.cc) %></dd>
|
||||
<% end
|
||||
if @mail.bcc %>
|
||||
<dt><%=_('BCC')%></dt><dd><%= CGI.escapeHTML(@mail.bcc) %></dd>
|
||||
<% end %>
|
||||
<dt><%=_('Subject')%></dt><dd><%= CGI.escapeHTML(@mail.subject) %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,48 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><span><%= _('Folders') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_back_to_messages%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<% content_for('sidebar') { %>
|
||||
<div id="folders">
|
||||
<h4><%=_('Add folder')%></h4>
|
||||
<hr/>
|
||||
<form action="/webmail/webmail/manage_folders" method="post">
|
||||
<ul>
|
||||
<li><label for='folder_name'><%=_('Name')%>:</label></li>
|
||||
<li><input type="text" name="folder_name" value="" size="18" id='folder_name'/></li>
|
||||
<li><input type="submit" name="op" value="<%=_('Add folder')%>"/></li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div id="messages">
|
||||
<div id='msg-fl-list'>
|
||||
<table>
|
||||
<thead><tr><th><%=_('Folder')%></th><th><%= _('Total messages') %></th><th><%= _('Unseen') %></th></tr></thead>
|
||||
<tbody>
|
||||
<% for folder in @folders %>
|
||||
<tr>
|
||||
<td><%=folder_manage_link(folder)%></td>
|
||||
<td><%= folder.total %></td>
|
||||
<td><%= folder.unseen > 0 ? "<b>#{folder.unseen}</b>" : "#{folder.unseen}" %></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,48 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><span><%= _('Folders') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_refresh%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<% content_for('sidebar') { %>
|
||||
<div id="folders">
|
||||
<h4><%=_('Folders')%><br/><%=link_manage_folders%></h4>
|
||||
<hr/>
|
||||
<ul> <% for folder in @folders %>
|
||||
<li><%=folder_link(folder)%></li> <% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% } %>
|
||||
<div id="messages">
|
||||
|
||||
<div id="msgshow">
|
||||
<div id="topmenu">
|
||||
<ul class="actionmenu">
|
||||
<li>
|
||||
<%= link_to(_("« Back to list"), :controller=>"/webmail/webmail", :action=>"messages") %>
|
||||
</li>
|
||||
<li><%=link_reply_to_sender(@msg_id)%></li>
|
||||
<li><%=link_forward_message(@msg_id)%></li>
|
||||
<li><%=link_flag_for_deletion(@msg_id)%></li>
|
||||
<li><%=link_view_source(@msg_id)%></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<%= mail2html(@mail, @msg_id) %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><span><%= _('Folders') %></span>
|
||||
<ul id="secondary">
|
||||
<li><%=link_refresh%></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><%=link_mail_prefs%></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
|
||||
<% content_for('sidebar') { %>
|
||||
<div id="folders">
|
||||
<h4><%=_('Folders')%><br/><%=link_manage_folders%></h4>
|
||||
<hr/>
|
||||
<ul> <% for folder in @folders %>
|
||||
<li><%=folder_link(folder)%></li> <% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="text-align: center; padding: 10px;">
|
||||
<input type="button" value="<%= _('Logout')%>" onclick="window.location='/login/logout'">
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div id="messages">
|
||||
<div id="msglist">
|
||||
<h2><%= @folder_name %></h2>
|
||||
<%= start_form_tag({:controller=>'/webmail/webmail', :action=>'messages'})%>
|
||||
<div class='notviscode'><input type="submit" name="op" value="<%=_('Search')%>" /></div>
|
||||
<input type="hidden" name="page" value="<%=@page%>"/>
|
||||
|
||||
<a href='#' onclick='toggle_msg_operations(true);'>
|
||||
<%=_('Operations')%><img id='img_msgops' alt='open' src='/images/list_<%=@ops_img_src%>.gif'/>
|
||||
</a>
|
||||
|
||||
<div id="msgops" class='<%=@ops_class%>'>
|
||||
<h4><%=_('Operations on marked messages')%></h4>
|
||||
<span id="opch">
|
||||
<%= submit_tag(_('delete'), :name=>'op')%>
|
||||
<%= submit_tag(_('copy'), :name=> 'op')%>
|
||||
<%= submit_tag(_('move'), :name=>'op')%>
|
||||
<%= submit_tag(_('mark read'), :name=>'op')%>
|
||||
<%= submit_tag(_('mark unread'), :name=>'op')%>
|
||||
</span><br/>
|
||||
<span id="destp">
|
||||
<%=_('Destination for move and copy operations')%>
|
||||
<select name="cpdest" size="1">
|
||||
<% for folder in @folders %>
|
||||
<option value="<%=folder.name%>"><%=folder.name%></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
<%= render_partial "search" %>
|
||||
<%= page_navigation_webmail @pages if @pages.page_count > 1 %>
|
||||
<table width='98%'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="1%"><input type="checkbox" name="allbox" onclick="checkAll(this.form)" style="margin: 0 0 0 4px" /></th>
|
||||
<% if @folder_name == CDF::CONFIG[:mail_sent] %>
|
||||
<th width="20%"><%= link_to(_('To'), :controller=>'/webmail/webmail', :action=>'messages', :op=>'SORT', :page=>@page, :scc=>'to_flat')%></th>
|
||||
<% else %>
|
||||
<th width="20%"><%= link_to(_('From'), :controller=>'/webmail/webmail', :action=>'messages', :op=>'SORT', :page=>@page, :scc=>'from_flat')%></th>
|
||||
<% end%>
|
||||
<th width='60%'><%= link_to(_('Subject'), :controller=>'/webmail/webmail', :action=>'messages', :op=>'SORT', :page=>@page, :scc=>'subject')%></th>
|
||||
<th><%= link_to(_('Date'), :controller=>'/webmail/webmail', :action=>'messages', :op=>'SORT', :page=>@page, :scc=>'date')%></th>
|
||||
<th><%= link_to(_('Size'), :controller=>'/webmail/webmail', :action=>'messages', :op=>'SORT', :page=>@page, :scc=>'size')%></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% for message in @messages %>
|
||||
<%= render_partial 'webmail/webmail/message_row', message %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= page_navigation_webmail @pages if @pages.page_count > 1 %>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -1 +0,0 @@
|
|||
No attachment found!
|
|
@ -1,52 +0,0 @@
|
|||
<h1><%=_('Mailbox')%></h1>
|
||||
<div id="header">
|
||||
<ul id="primary">
|
||||
<li><%=link_folders%></li>
|
||||
<li><%=link_send_mail%></li>
|
||||
<li><span><%= _('Preferences') %></span></li>
|
||||
<li><%=link_mail_filters%></li>
|
||||
<li><%=link_main%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab_main">
|
||||
<div id="tab_content">
|
||||
<div id="prefs">
|
||||
<form action="/webmail/webmail/prefs" method="post">
|
||||
<%= hidden_field "mailpref", "id" %>
|
||||
<%= hidden_field "mailpref", "customer_id" %>
|
||||
<table class="edit">
|
||||
<%= form_input(:text_field, 'customer', 'fname', _('First name'), 'class'=>'two_columns') %>
|
||||
<%= form_input(:text_field, 'customer', 'lname', _('Last name'), 'class'=>'two_columns') %>
|
||||
<tr class="two_rows">
|
||||
<td><label><%=_('Send type message')%></label></td>
|
||||
<td><select name="mailpref[mail_type]">
|
||||
<%= options_for_select(CDF::CONFIG[:mail_send_types], @mailpref.mail_type)%>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr class="two_rows">
|
||||
<td><label><%=_('Messages per page')%></label></td>
|
||||
<td><select name="mailpref[wm_rows]">
|
||||
<%= options_for_select(CDF::CONFIG[:mail_message_rows], @mailpref.wm_rows)%>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr class="two_rows">
|
||||
<td><label for="mailpref_check_external_mail"><%=_('Check external mail?')%></label></td>
|
||||
<td>
|
||||
<%=check_box('mailpref', 'check_external_mail')%>
|
||||
<%=_('Note that by selecting this option webmail system will try to log you using your original email on a local server.')%>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="two_rows">
|
||||
<td colspan='2' class="buttonBar">
|
||||
<input type="submit" name="op" value="<%=_('Save')%>"/>
|
||||
<input type="button" value="<%=_('Cancel')%>" onclick="window.location='/webmail/webmail/folders'"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><%=_('Mailr')%></title>
|
||||
<link rel="stylesheet" href="/stylesheets/webmail/webmail.css" type="text/css" media="screen" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="msg_source">
|
||||
<%=@msg_source%>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,494 +0,0 @@
|
|||
require 'cdfmail'
|
||||
require 'net/smtp'
|
||||
require 'net/imap'
|
||||
require 'mail2screen'
|
||||
require 'ezcrypto'
|
||||
|
||||
class Webmail::WebmailController < ApplicationController
|
||||
# uses_component_template_root
|
||||
|
||||
# Administrative functions
|
||||
before_filter :login_required
|
||||
|
||||
before_filter :obtain_cookies_for_search_and_nav, :only=>[:messages]
|
||||
|
||||
layout "public", :except => [:view_source, :download]
|
||||
|
||||
before_filter :load_imap_session
|
||||
|
||||
after_filter :close_imap_session
|
||||
|
||||
# model :filter, :expression, :mail_pref, :customer
|
||||
|
||||
BOOL_ON = "on"
|
||||
|
||||
def index
|
||||
redirect_to(:action=>"messages")
|
||||
end
|
||||
|
||||
def error_connection
|
||||
end
|
||||
|
||||
def refresh
|
||||
@mailbox.reload
|
||||
@folders = @mailbox.folders
|
||||
redirect_to(:action=>'messages')
|
||||
end
|
||||
|
||||
def manage_folders
|
||||
if operation_param == _('Add folder')
|
||||
@mailbox.create_folder(CDF::CONFIG[:mail_inbox]+"."+@params["folder_name"])
|
||||
elsif operation_param == _('(Delete)')
|
||||
@mailbox.delete_folder(@params["folder_name"])
|
||||
elsif operation_param == _('(Subscribe)')
|
||||
elsif operation_param == _('(Select)')
|
||||
end
|
||||
@folders = @mailbox.folders
|
||||
end
|
||||
|
||||
def messages
|
||||
@session["return_to"] = nil
|
||||
@search_field = @params['search_field']
|
||||
@search_value = @params['search_value']
|
||||
|
||||
# handle sorting - tsort session field contains last reverse or no for field
|
||||
# and lsort - last sort field
|
||||
if @session['tsort'].nil? or @session['lsort'].nil?
|
||||
@session['lsort'] = "DATE"
|
||||
@session['tsort'] = {"DATE" => true, "FROM" => true, "SUBJECT" => true, "TO" => false}
|
||||
end
|
||||
|
||||
case operation_param
|
||||
when _('copy') # copy
|
||||
msg_ids = []
|
||||
messages_param.each { |msg_id, bool|
|
||||
msg_ids << msg_id.to_i if bool == BOOL_ON and dst_folder != @folder_name } if messages_param
|
||||
folder.copy_multiple(msg_ids, dst_folder) if msg_ids.size > 0
|
||||
when _('move') # move
|
||||
msg_ids = []
|
||||
messages_param.each { |msg_id, bool|
|
||||
msg_ids << msg_id.to_i if bool == BOOL_ON and dst_folder != @folder_name } if messages_param
|
||||
folder.move_multiple(msg_ids, dst_folder) if msg_ids.size > 0
|
||||
when _('delete') # delete
|
||||
msg_ids = []
|
||||
messages_param.each { |msg_id, bool| msg_ids << msg_id.to_i if bool == BOOL_ON } if messages_param
|
||||
folder.delete_multiple(msg_ids) if msg_ids.size > 0
|
||||
when _('mark read') # mark as read
|
||||
messages_param.each { |msg_id, bool| msg = folder.mark_read(msg_id.to_i) if bool == BOOL_ON } if messages_param
|
||||
when _('mark unread') # mark as unread
|
||||
messages_param.each { |msg_id, bool| msg = folder.mark_unread(msg_id.to_i) if bool == BOOL_ON } if messages_param
|
||||
when "SORT"
|
||||
@session['lsort'] = sort_query = @params["scc"]
|
||||
@session['tsort'][sort_query] = (@session['tsort'][sort_query]? false : true)
|
||||
@search_field, @search_value = @session['search_field'], @session['search_value']
|
||||
when _('Search') # search
|
||||
@session['search_field'] = @search_field
|
||||
@session['search_value'] = @search_value
|
||||
when _('Show all') # search
|
||||
@session['search_field'] = @search_field = nil
|
||||
@session['search_value'] = @search_value = nil
|
||||
else
|
||||
# get search criteria from session
|
||||
@search_field = @session['search_field']
|
||||
@search_value = @session['search_value']
|
||||
end
|
||||
|
||||
sort_query = @session['lsort']
|
||||
reverse_sort = @session['tsort'][sort_query]
|
||||
query = ["ALL"]
|
||||
@page = @params["page"]
|
||||
@page ||= @session['page']
|
||||
@session['page'] = @page
|
||||
if @search_field and @search_value and not(@search_field.strip() == "") and not(@search_value.strip() == "")
|
||||
@pages = Paginator.new self, 0, get_mail_prefs.wm_rows, @page
|
||||
@messages = folder.messages_search([@search_field, @search_value], sort_query + (reverse_sort ? ' desc' : ' asc'))
|
||||
else
|
||||
@pages = Paginator.new self, folder.total, get_mail_prefs.wm_rows, @page
|
||||
@messages = folder.messages(@pages.current.first_item - 1, get_mail_prefs.wm_rows, sort_query + (reverse_sort ? ' desc' : ' asc'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def delete
|
||||
@msg_id = msg_id_param.to_i
|
||||
folder.messages().delete(@msg_id)
|
||||
redirect_to(:action=>"messages")
|
||||
end
|
||||
|
||||
def reply # not ready at all
|
||||
@msg_id = msg_id_param.to_i
|
||||
@imapmail = folder.message(@msg_id)
|
||||
fb = @imapmail.full_body
|
||||
@tmail = TMail::Mail.parse(fb)
|
||||
|
||||
@mail = prepare_mail
|
||||
@mail.reply(@tmail, fb, get_mail_prefs.mail_type)
|
||||
|
||||
render_action("compose")
|
||||
end
|
||||
|
||||
def forward
|
||||
@msg_id = msg_id_param.to_i
|
||||
@imapmail = folder.message(@msg_id)
|
||||
fb = @imapmail.full_body
|
||||
@tmail = TMail::Mail.parse(fb)
|
||||
|
||||
@mail = prepare_mail
|
||||
@mail.forward(@tmail, fb)
|
||||
|
||||
render_action("compose")
|
||||
end
|
||||
|
||||
def compose
|
||||
if @mail.nil?
|
||||
operation = operation_param
|
||||
if operation == _('Send')
|
||||
@mail = create_mail
|
||||
encmail = @mail.send_mail
|
||||
get_imap_session
|
||||
@mailbox.message_sent(encmail)
|
||||
|
||||
# delete temporary files (attachments)
|
||||
@mail.delete_attachments()
|
||||
return render("webmail/webmail/mailsent")
|
||||
elsif operation == _('Add')
|
||||
@mail = create_mail
|
||||
attachment = CDF::Attachment.new(@mail)
|
||||
attachment.file = @params['attachment']
|
||||
else
|
||||
# default - new email create
|
||||
@mail = create_mail
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def empty # empty trash folder (works for any one else :-))
|
||||
folder.messages(0, -1).each{ |message|
|
||||
folder.delete(message)
|
||||
}
|
||||
folder.expunge
|
||||
redirect_to(:action=>"messages")
|
||||
end
|
||||
|
||||
def message
|
||||
@msg_id = msg_id_param
|
||||
@imapmail = folder.message(@msg_id)
|
||||
folder.mark_read(@imapmail.uid) if @imapmail.unread
|
||||
@mail = TMail::Mail.parse(@imapmail.full_body)
|
||||
end
|
||||
|
||||
def download
|
||||
msg_id = msg_id_param
|
||||
imapmail = folder.message(msg_id)
|
||||
mail = TMail::Mail.parse(imapmail.full_body)
|
||||
|
||||
if mail.multipart?
|
||||
get_parts(mail).each { |part|
|
||||
return send_part(part) if part.header and part.header['content-type']['name'] == @params['ctype']
|
||||
}
|
||||
render("webmail/webmail/noattachment")
|
||||
else
|
||||
render("webmail/webmail/noattachment")
|
||||
end
|
||||
end
|
||||
|
||||
def prefs
|
||||
@customer = Customer.find(logged_customer)
|
||||
if not(@mailpref = MailPref.find_by_customer(logged_customer))
|
||||
@mailpref = MailPref.create("customer_id"=>logged_customer)
|
||||
end
|
||||
|
||||
if @params['op'] == _('Save')
|
||||
if @params['customer']
|
||||
@customer.fname = @params['customer']['fname']
|
||||
@customer.lname = @params['customer']['lname']
|
||||
@customer.save
|
||||
end
|
||||
@mailpref.attributes = @params["mailpref"]
|
||||
@mailpref.save
|
||||
@session["wmimapseskey"] = nil
|
||||
redirect_to(:action=>"messages")
|
||||
end
|
||||
end
|
||||
|
||||
# Message filters management
|
||||
def filters
|
||||
end
|
||||
|
||||
def filter
|
||||
if @params['op']
|
||||
@filter = Filter.new(@params['filter'])
|
||||
@filter.customer_id = logged_customer
|
||||
@params['expression'].each { |index, expr| @filter.expressions << Expression.new(expr) unless expr["expr_value"].nil? or expr["expr_value"].strip == "" }
|
||||
case @params['op']
|
||||
when _('Add')
|
||||
@filter.expressions << Expression.new
|
||||
when _('Save')
|
||||
if @params['filter']['id'] and @params['filter']['id'] != ""
|
||||
@sf = Filter.find(@params['filter']['id'])
|
||||
@sf.name, @sf.destination_folder = @filter.name, @filter.destination_folder
|
||||
@sf.expressions.each{|expr| Expression.delete(expr.id) }
|
||||
@filter.expressions.each {|expr| @sf.expressions << Expression.create(expr.attributes) }
|
||||
else
|
||||
@sf = Filter.create(@filter.attributes)
|
||||
@sf.order_num = @user.filters.size
|
||||
@filter.expressions.each {|expr| @sf.expressions << Expression.create(expr.attributes) }
|
||||
end
|
||||
# may be some validation will be needed
|
||||
@sf.save
|
||||
@user.serialize_to_file
|
||||
return redirect_to(:action=>"filters")
|
||||
end
|
||||
@expressions = @filter.expressions
|
||||
else
|
||||
@filter = Filter.find(@params["id"]) if @params["id"]
|
||||
@expressions = @filter.expressions
|
||||
end
|
||||
@destfolders = get_to_folders
|
||||
end
|
||||
|
||||
def filter_delete
|
||||
Filter.delete(@params["id"])
|
||||
# reindex other filters
|
||||
@user = Customer.find(logged_customer)
|
||||
findex = 0
|
||||
@user.filters.each { |filter|
|
||||
findex = findex + 1
|
||||
filter.order_num = findex
|
||||
filter.save
|
||||
}
|
||||
@user.serialize_to_file
|
||||
redirect_to :action=>"filters"
|
||||
end
|
||||
|
||||
def filter_up
|
||||
filt = @user.filters.find(@params['id'])
|
||||
ufilt = @user.filters.find_all("order_num = #{filt.order_num - 1}").first
|
||||
ufilt.order_num = ufilt.order_num + 1
|
||||
filt.order_num = filt.order_num - 1
|
||||
ufilt.save
|
||||
filt.save
|
||||
@user.serialize_to_file
|
||||
redirect_to :action=>"filters"
|
||||
end
|
||||
|
||||
def filter_down
|
||||
filt = Filter.find(@params["id"])
|
||||
dfilt = @user.filters[filt.order_num]
|
||||
dfilt.order_num = dfilt.order_num - 1
|
||||
filt.order_num = filt.order_num + 1
|
||||
dfilt.save
|
||||
filt.save
|
||||
@user.serialize_to_file
|
||||
redirect_to :action=>"filters"
|
||||
end
|
||||
|
||||
def filter_add
|
||||
@filter = Filter.new
|
||||
@filter.expressions << Expression.new
|
||||
@expressions = @filter.expressions
|
||||
@destfolders = get_to_folders
|
||||
render_action("filter")
|
||||
end
|
||||
# end of filters
|
||||
|
||||
def view_source
|
||||
@msg_id = msg_id_param.to_i
|
||||
@imapmail = folder.message(@msg_id)
|
||||
@msg_source = CGI.escapeHTML(@imapmail.full_body).gsub("\n", "<br/>")
|
||||
end
|
||||
|
||||
def auto_complete_for_mail_to
|
||||
auto_complete_responder_for_contacts params[:mail][:to]
|
||||
end
|
||||
|
||||
def auto_complete_for_mail_cc
|
||||
auto_complete_responder_for_contacts params[:mail][:cc]
|
||||
end
|
||||
|
||||
def auto_complete_for_mail_bcc
|
||||
auto_complete_responder_for_contacts params[:mail][:bcc]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def auto_complete_responder_for_contacts(value)
|
||||
# first split by "," and take last name
|
||||
searchName = value.split(',').last.strip
|
||||
|
||||
# if there are 2 names search by them
|
||||
if searchName.split.size > 1
|
||||
fname, lname = searchName.split.first, searchName.split.last
|
||||
conditions = ['customer_id = ? and LOWER(fname) LIKE ? and LOWER(lname) like ?', logged_customer, fname.downcase + '%', lname.downcase + '%']
|
||||
else
|
||||
conditions = ['customer_id = ? and LOWER(fname) LIKE ?', logged_customer, searchName.downcase + '%']
|
||||
end
|
||||
@contacts = Contact.find(:all, :conditions => conditions, :order => 'fname ASC',:limit => 8)
|
||||
render :partial => 'contacts'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def additional_scripts()
|
||||
'<link rel="stylesheet" href="/stylesheets/webmail/webmail.css" type="text/css" media="screen" />'<<
|
||||
'<script type="text/javascript" src="/javascripts/webmail.js"></script>'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_upass
|
||||
if CDF::CONFIG[:crypt_session_pass]
|
||||
EzCrypto::Key.decrypt_with_password(CDF::CONFIG[:encryption_password], CDF::CONFIG[:encryption_salt], @session["wmp"])
|
||||
else
|
||||
# retrun it plain
|
||||
@session["wmp"]
|
||||
end
|
||||
end
|
||||
|
||||
def get_to_folders
|
||||
res = Array.new
|
||||
@folders.each{|f| res << f unless f.name == CDF::CONFIG[:mail_sent] or f.name == CDF::CONFIG[:mail_inbox] }
|
||||
res
|
||||
end
|
||||
|
||||
def load_imap_session
|
||||
return if ['compose', 'prefs', 'error_connection'].include?(action_name)
|
||||
get_imap_session
|
||||
end
|
||||
|
||||
def get_imap_session
|
||||
begin
|
||||
@mailbox = IMAPMailbox.new
|
||||
uname = (get_mail_prefs.check_external_mail == 1 ? user.email : user.local_email)
|
||||
upass = get_upass
|
||||
@mailbox.connect(uname, upass)
|
||||
load_folders
|
||||
rescue Exception => ex
|
||||
logger.error("Exception on loggin webmail session - #{ex} - #{ex.backtrace.join("\t\n")}")
|
||||
render_action "error_connection"
|
||||
end
|
||||
end
|
||||
|
||||
def close_imap_session
|
||||
return if @mailbox.nil? or not(@mailbox.connected)
|
||||
@mailbox.disconnect
|
||||
@mailbox = nil
|
||||
end
|
||||
|
||||
def have_to_load_folders?
|
||||
return true if ['messages', 'delete', 'reply', 'forward', 'empty', 'message', 'download',
|
||||
'filter', 'filter_add', 'view_source'].include?(action_name)
|
||||
return false
|
||||
end
|
||||
|
||||
def load_folders
|
||||
if have_to_load_folders?()
|
||||
if @params["folder_name"]
|
||||
@folder_name = @params["folder_name"]
|
||||
else
|
||||
@folder_name = @session["folder_name"] ? @session["folder_name"] : CDF::CONFIG[:mail_inbox]
|
||||
end
|
||||
@session["folder_name"] = @folder_name
|
||||
@folders = @mailbox.folders if @folders.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def create_mail
|
||||
m = CDF::Mail.new(user.mail_temporary_path)
|
||||
if @params["mail"]
|
||||
ma = @params["mail"]
|
||||
m.body, m.content_type, m.from, m.to, m.cc, m.bcc, m.subject = ma["body"], ma["content_type"], ma["from"], ma["to"], ma["cc"], ma["bcc"], ma["subject"]
|
||||
if @params["att_files"]
|
||||
att_files, att_tfiles, att_ctypes = @params["att_files"], @params["att_tfiles"], @params["att_ctypes"]
|
||||
att_files.each {|i, value|
|
||||
att = CDF::Attachment.new(m)
|
||||
att.filename, att.temp_filename, att.content_type = value, att_tfiles[i], att_ctypes[i]
|
||||
}
|
||||
end
|
||||
else
|
||||
m.from, m.content_type = user.friendlly_local_email, get_mail_prefs.mail_type
|
||||
end
|
||||
m.customer_id = logged_customer
|
||||
m
|
||||
end
|
||||
|
||||
def prepare_mail
|
||||
m = CDF::Mail.new(user.mail_temporary_path)
|
||||
m.from, m.content_type = user.friendlly_local_email, get_mail_prefs.mail_type
|
||||
m
|
||||
end
|
||||
|
||||
def user
|
||||
@user = Customer.find(logged_customer) if @user.nil?
|
||||
@user
|
||||
end
|
||||
|
||||
def get_mail_prefs
|
||||
if not(@mailprefs)
|
||||
if not(@mailprefs = MailPref.find_by_customer(logged_customer))
|
||||
@mailprefs = MailPref.create("customer_id"=>logged_customer)
|
||||
end
|
||||
end
|
||||
@mailprefs
|
||||
end
|
||||
|
||||
def send_part(part)
|
||||
if part.content_type == "text/html"
|
||||
disposition = "inline"
|
||||
elsif part.content_type.include?("image/")
|
||||
disposition = "inline"
|
||||
else
|
||||
disposition = "attachment"
|
||||
end
|
||||
@headers['Content-Length'] = part.body.size
|
||||
@response.headers['Accept-Ranges'] = 'bytes'
|
||||
@headers['Content-type'] = part.content_type.strip
|
||||
@headers['Content-Disposition'] = disposition << %(; filename="#{part.header['content-type']['name']}")
|
||||
render_text part.body
|
||||
end
|
||||
|
||||
def get_parts(mail)
|
||||
parts = Array.new
|
||||
parts << mail
|
||||
mail.parts.each { |part|
|
||||
if part.multipart?
|
||||
parts = parts.concat(get_parts(part))
|
||||
elsif part.content_type and part.content_type.include?("rfc822")
|
||||
parts = parts.concat(get_parts(TMail::Mail.parse(part.body))) << part
|
||||
else
|
||||
parts << part
|
||||
end
|
||||
}
|
||||
parts
|
||||
end
|
||||
|
||||
def obtain_cookies_for_search_and_nav
|
||||
@srch_class = ((cookies['_wmlms'] and cookies['_wmlms'] == 'closed') ? 'closed' : 'open')
|
||||
@srch_img_src = ((cookies['_wmlms'] and cookies['_wmlms'] == 'closed') ? 'closed' : 'opened')
|
||||
@ops_class = ((cookies['_wmlmo'] and cookies['_wmlmo'] == 'closed') ? 'closed' : 'open')
|
||||
@ops_img_src = ((cookies['_wmlmo'] and cookies['_wmlmo'] == 'closed') ? 'closed' : 'opened')
|
||||
end
|
||||
|
||||
###################################################################
|
||||
### Some fixed parameters and session variables
|
||||
###################################################################
|
||||
def folder
|
||||
@folders[@folder_name]
|
||||
end
|
||||
|
||||
def msg_id_param
|
||||
@params["msg_id"]
|
||||
end
|
||||
|
||||
def messages_param
|
||||
@params["messages"]
|
||||
end
|
||||
|
||||
def dst_folder
|
||||
@params["cpdest"]
|
||||
end
|
||||
|
||||
def operation_param
|
||||
@params["op"]
|
||||
end
|
||||
end
|
|
@ -1,211 +0,0 @@
|
|||
require 'cdfutils'
|
||||
require 'mail2screen'
|
||||
|
||||
module Webmail::WebmailHelper
|
||||
include Mail2Screen
|
||||
def link_folders
|
||||
link_to(_('Folders'), :controller=>"/webmail/webmail", :action=>"messages")
|
||||
end
|
||||
|
||||
def link_send_mail
|
||||
link_to(_('Compose'), :controller=>"/webmail/webmail", :action=>"compose")
|
||||
end
|
||||
|
||||
def link_compose_new
|
||||
link_to(_('Compose new mail'), :controller=>"/webmail/webmail", :action=>"compose")
|
||||
end
|
||||
|
||||
def link_refresh
|
||||
link_to(_('Refresh'), :controller=>"/webmail/webmail", :action=>"refresh")
|
||||
end
|
||||
|
||||
def link_message_list
|
||||
link_to(_('Message list'), :controller=>"/webmail/webmail", :action=>"messages")
|
||||
end
|
||||
|
||||
def link_reply_to_sender(msg_id)
|
||||
link_to(_('Reply'), :controller=>"/webmail/webmail", :action=>"reply", :params=>{"msg_id"=>msg_id})
|
||||
end
|
||||
|
||||
def link_forward_message(msg_id)
|
||||
link_to(_('Forward'), :controller=>"/webmail/webmail", :action=>"forward", :params=>{"msg_id"=>msg_id})
|
||||
end
|
||||
|
||||
def link_flag_for_deletion(msg_id)
|
||||
link_to(_('Delete'), :controller=>"/webmail/webmail", :action=>"delete", :params=>{"msg_id"=>msg_id})
|
||||
end
|
||||
|
||||
def link_view_source(msg_id)
|
||||
link_to(_('View source'), {:controller=>"/webmail/webmail", :action=>"view_source", :params=>{"msg_id"=>msg_id}}, {'target'=>"_blank"})
|
||||
end
|
||||
|
||||
def link_manage_folders
|
||||
link_to(_('add/edit'), :controller=>"/webmail/webmail", :action=>"manage_folders")
|
||||
end
|
||||
|
||||
def link_back_to_messages
|
||||
link_to("«" << _('Back to messages'), :controller=>"/webmail/webmail", :action=>"messages")
|
||||
end
|
||||
|
||||
def link_mail_prefs
|
||||
link_to(_('Preferences'), :controller=>"/webmail/webmail", :action=>"prefs")
|
||||
end
|
||||
|
||||
def link_mail_filters
|
||||
link_to(_('Filters'), :controller=>"/webmail/webmail", :action=>"filters")
|
||||
end
|
||||
|
||||
def link_filter_add
|
||||
link_to(_('Add filter'), :controller=>'/webmail/webmail', :action=>'filter_add')
|
||||
end
|
||||
|
||||
def folder_link(folder)
|
||||
if folder.attribs.include? :Noselect
|
||||
return folder.name
|
||||
end
|
||||
unseen_messages = folder.unseen
|
||||
if unseen_messages > 0
|
||||
fn = "#{short_fn(folder)} (#{folder.unseen})"
|
||||
else
|
||||
fn = "#{short_fn(folder)}"
|
||||
end
|
||||
if folder.name == CDF::CONFIG[:mail_trash]
|
||||
(unseen_messages > 0 ? "<b>" : "" ) <<
|
||||
link_to( fn, :controller=>"/webmail/webmail", :action=>"messages", :params=>{"folder_name"=>folder.name}) <<
|
||||
" " << link_to(_('(Empty)'), {:controller=>"/webmail/webmail", :action=>"empty", :params=>{"folder_name"=>folder.name}}, :confirm => _('Do you really want to empty trash?')) <<
|
||||
(unseen_messages > 0 ? "</b>" : "" )
|
||||
else
|
||||
(unseen_messages > 0 ? "<b>" : "" ) <<
|
||||
link_to( fn, :controller=>"/webmail/webmail", :action=>"messages", :params=>{"folder_name"=>folder.name}) <<
|
||||
(unseen_messages > 0 ? "</b>" : "" )
|
||||
end
|
||||
end
|
||||
|
||||
def short_fn(folder)
|
||||
if folder.name.include? folder.delim
|
||||
" " + folder.name.split(folder.delim).last
|
||||
else
|
||||
folder.name
|
||||
end
|
||||
end
|
||||
|
||||
def folder_manage_link(folder)
|
||||
if folder.name == CDF::CONFIG[:mail_trash] or folder.name == CDF::CONFIG[:mail_inbox] or folder.name == CDF::CONFIG[:mail_sent]
|
||||
short_fn(folder)
|
||||
else
|
||||
return short_fn(folder) +
|
||||
(" " + link_to(_('(Delete)'), :controller=>"/webmail/webmail", :action=>"manage_folders", :params=>{"op"=>_('(Delete)'), "folder_name"=>folder.name}))
|
||||
end
|
||||
end
|
||||
|
||||
def message_date(datestr)
|
||||
t = Time.now
|
||||
begin
|
||||
if datestr.kind_of?(String)
|
||||
d = (Time.rfc2822(datestr) rescue Time.parse(value)).localtime
|
||||
else
|
||||
d = datestr
|
||||
end
|
||||
if d.day == t.day and d.month == t.month and d.year == t.year
|
||||
d.strftime("%H:%M")
|
||||
else
|
||||
d.strftime("%Y-%m-%d")
|
||||
end
|
||||
rescue
|
||||
begin
|
||||
d = imap2time(datestr)
|
||||
if d.day == t.day and d.month == t.month and d.year == t.year
|
||||
d.strftime("%H:%M")
|
||||
else
|
||||
d.strftime("%Y-%m-%d")
|
||||
end
|
||||
rescue
|
||||
datestr
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def attachment(att, index)
|
||||
ret = "#{att.filename}"
|
||||
# todo: add link to delete attachment
|
||||
#ret <<
|
||||
ret << "<input type='hidden' name='att_files[#{index}]' value='#{att.filename}'/>"
|
||||
ret << "<input type='hidden' name='att_tfiles[#{index}]' value='#{att.temp_filename}'/>"
|
||||
ret << "<input type='hidden' name='att_ctypes[#{index}]' value='#{att.content_type}'/>"
|
||||
end
|
||||
|
||||
def link_filter_up(filter_id)
|
||||
link_to(_('Up'), :controller=>"/webmail/webmail", :action=>"filter_up", :id=>filter_id)
|
||||
end
|
||||
|
||||
def link_filter_down(filter_id)
|
||||
link_to(_('Down'), :controller=>"/webmail/webmail", :action=>"filter_down", :id=>filter_id)
|
||||
end
|
||||
|
||||
def link_filter_edit(filter_id)
|
||||
link_to(_('Edit'), :controller=>"/webmail/webmail", :action=>"filter", :id=>filter_id)
|
||||
end
|
||||
|
||||
def link_filter_delete(filter_id)
|
||||
link_to(_('Delete'), :controller=>"/webmail/webmail", :action=>"filter_delete", :id=>filter_id)
|
||||
end
|
||||
|
||||
def page_navigation_webmail(pages)
|
||||
nav = "<p class='paginator'><small>"
|
||||
|
||||
nav << "(#{pages.length} #{_('Pages')}) "
|
||||
|
||||
window_pages = pages.current.window.pages
|
||||
nav << "..." unless window_pages[0].first?
|
||||
for page in window_pages
|
||||
if pages.current == page
|
||||
nav << page.number.to_s << " "
|
||||
else
|
||||
nav << link_to(page.number, :controller=>"/webmail/webmail", :action=>'messages', :page=>page.number) << " "
|
||||
end
|
||||
end
|
||||
nav << "..." unless window_pages[-1].last?
|
||||
nav << " "
|
||||
|
||||
nav << link_to(_('First'), :controller=>"/webmail/webmail", :action=>'messages', :page=>@pages.first.number) << " | " unless @pages.current.first?
|
||||
nav << link_to(_('Prev'), :controller=>"/webmail/webmail", :action=>'messages', :page=>@pages.current.previous.number) << " | " if @pages.current.previous
|
||||
nav << link_to(_('Next'), :controller=>"/webmail/webmail", :action=>'messages', :page=>@pages.current.next.number) << " | " if @pages.current.next
|
||||
nav << link_to(_('Last'), :controller=>"/webmail/webmail", :action=>'messages', :page=>@pages.last.number) << " | " unless @pages.current.last?
|
||||
|
||||
nav << "</small></p>"
|
||||
|
||||
return nav
|
||||
end
|
||||
|
||||
def parse_subject(subject)
|
||||
begin
|
||||
if mime_encoded?(subject)
|
||||
if mime_decode(subject) == ''
|
||||
_('(No subject)')
|
||||
else
|
||||
mime_decode(subject)
|
||||
end
|
||||
else
|
||||
if from_qp(subject) == ''
|
||||
_('(No subject)')
|
||||
else
|
||||
from_qp(subject)
|
||||
end
|
||||
end
|
||||
rescue Exception => ex
|
||||
RAILS_DEFAULT_LOGGER.debug('Exception occured - #{ex}')
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
def message_size(size)
|
||||
if size / (1024*1024) > 0
|
||||
return "#{(size / (1024*1024)).round} MB"
|
||||
elsif size / 1024 > 0
|
||||
return "#{(size / (1024)).round} KB"
|
||||
else
|
||||
return "#{size} B"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue