Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
92 KB
Referenced Files
None
Subscribers
None
diff --git a/plugins/tasklist/jquery.tagedit.js b/plugins/tasklist/jquery.tagedit.js
old mode 100755
new mode 100644
index d70cb327..7d7bf0a3
--- a/plugins/tasklist/jquery.tagedit.js
+++ b/plugins/tasklist/jquery.tagedit.js
@@ -1,535 +1,583 @@
/*
* Tagedit - jQuery Plugin
* The Plugin can be used to edit tags from a database the easy way
*
* Examples and documentation at: tagedit.webwork-albrecht.de
*
* Copyright (c) 2010 Oliver Albrecht <info@webwork-albrecht.de>
+* Copyright (c) 2012 Thomas Brüderli <thomas@roundcube.net>
*
* License:
* This work is licensed under a MIT License
* http://www.opensource.org/licenses/mit-license.php
*
* @author Oliver Albrecht Mial: info@webwork-albrecht.de Twitter: @webworka
-* @version 1.2.1 (11/2011)
+* @version 1.5.1 (10/2013)
* Requires: jQuery v1.4+, jQueryUI v1.8+, jQuerry.autoGrowInput
*
* Example of usage:
*
* $( "input.tag" ).tagedit();
*
* Possible options:
*
* autocompleteURL: '', // url for a autocompletion
* deleteEmptyItems: true, // Deletes items with empty value
* deletedPostfix: '-d', // will be put to the Items that are marked as delete
* addedPostfix: '-a', // will be put to the Items that are choosem from the database
* additionalListClass: '', // put a classname here if the wrapper ul shoud receive a special class
* allowEdit: true, // Switch on/off edit entries
* allowDelete: true, // Switch on/off deletion of entries. Will be ignored if allowEdit = false
* allowAdd: true, // switch on/off the creation of new entries
* direction: 'ltr' // Sets the writing direction for Outputs and Inputs
* animSpeed: 500 // Sets the animation speed for effects
* autocompleteOptions: {}, // Setting Options for the jquery UI Autocomplete (http://jqueryui.com/demos/autocomplete/)
* breakKeyCodes: [ 13, 44 ], // Sets the characters to break on to parse the tags (defaults: return, comma)
* checkNewEntriesCaseSensitive: false, // If there is a new Entry, it is checked against the autocompletion list. This Flag controlls if the check is (in-)casesensitive
* texts: { // some texts
* removeLinkTitle: 'Remove from list.',
* saveEditLinkTitle: 'Save changes.',
* deleteLinkTitle: 'Delete this tag from database.',
* deleteConfirmation: 'Are you sure to delete this entry?',
* deletedElementTitle: 'This Element will be deleted.',
* breakEditLinkTitle: 'Cancel'
* }
*/
(function($) {
$.fn.tagedit = function(options) {
/**
* Merge Options with defaults
*/
options = $.extend(true, {
// default options here
autocompleteURL: null,
+ checkToDeleteURL: null,
deletedPostfix: '-d',
addedPostfix: '-a',
additionalListClass: '',
allowEdit: true,
allowDelete: true,
allowAdd: true,
direction: 'ltr',
animSpeed: 500,
autocompleteOptions: {
select: function( event, ui ) {
$(this).val(ui.item.value).trigger('transformToTag', [ui.item.id]);
return false;
}
},
breakKeyCodes: [ 13, 44 ],
- checkNewEntriesCaseSensitive: false,
+ checkNewEntriesCaseSensitive: false,
texts: {
removeLinkTitle: 'Remove from list.',
saveEditLinkTitle: 'Save changes.',
deleteLinkTitle: 'Delete this tag from database.',
deleteConfirmation: 'Are you sure to delete this entry?',
deletedElementTitle: 'This Element will be deleted.',
- breakEditLinkTitle: 'Cancel'
+ breakEditLinkTitle: 'Cancel',
+ forceDeleteConfirmation: 'There are more records using this tag, are you sure do you want to remove it?'
},
tabindex: false
}, options || {});
// no action if there are no elements
if(this.length == 0) {
return;
}
// set the autocompleteOptions source
if(options.autocompleteURL) {
options.autocompleteOptions.source = options.autocompleteURL;
}
// Set the direction of the inputs
var direction= this.attr('dir');
if(direction && direction.length > 0) {
options.direction = this.attr('dir');
}
var elements = this;
var baseNameRegexp = new RegExp("^(.*)\\[([0-9]*?("+options.deletedPostfix+"|"+options.addedPostfix+")?)?\]$", "i");
var baseName = elements.eq(0).attr('name').match(baseNameRegexp);
if(baseName && baseName.length == 4) {
baseName = baseName[1];
}
else {
// Elementname does not match the expected format, exit
alert('elementname dows not match the expected format (regexp: '+baseNameRegexp+')')
return;
}
// read tabindex from source element
var ti;
if (!options.tabindex && (ti = elements.eq(0).attr('tabindex')))
options.tabindex = ti;
// init elements
inputsToList();
/**
* Creates the tageditinput from a list of textinputs
*
*/
function inputsToList() {
var html = '<ul class="tagedit-list '+options.additionalListClass+'">';
elements.each(function() {
var element_name = $(this).attr('name').match(baseNameRegexp);
if(element_name && element_name.length == 4 && (options.deleteEmptyItems == false || $(this).val().length > 0)) {
if(element_name[1].length > 0) {
var elementId = typeof element_name[2] != 'undefined'? element_name[2]: '';
html += '<li class="tagedit-listelement tagedit-listelement-old">';
html += '<span dir="'+options.direction+'">' + $(this).val() + '</span>';
html += '<input type="hidden" name="'+baseName+'['+elementId+']" value="'+$(this).val()+'" />';
html += '<a class="tagedit-close" title="'+options.texts.removeLinkTitle+'">x</a>';
html += '</li>';
}
}
});
// replace Elements with the list and save the list in the local variable elements
elements.last().after(html)
var newList = elements.last().next();
elements.remove();
elements = newList;
// Check if some of the elementshav to be marked as deleted
if(options.deletedPostfix.length > 0) {
elements.find('input[name$="'+options.deletedPostfix+'\]"]').each(function() {
markAsDeleted($(this).parent());
});
}
// put an input field at the End
// Put an empty element at the end
html = '<li class="tagedit-listelement tagedit-listelement-new">';
html += '<input type="text" name="'+baseName+'[]" value="" id="tagedit-input" disabled="disabled" class="tagedit-input-disabled" dir="'+options.direction+'"/>';
html += '</li>';
html += '</ul>';
elements
.append(html)
.attr('tabindex', options.tabindex) // set tabindex to <ul> to recieve focus
// Set function on the input
.find('#tagedit-input')
.attr('tabindex', options.tabindex)
.each(function() {
$(this).autoGrowInput({comfortZone: 15, minWidth: 15, maxWidth: 20000});
- // Event ist triggert in case of choosing an item from the autocomplete, or finish the input
+ // Event is triggert in case of choosing an item from the autocomplete, or finish the input
$(this).bind('transformToTag', function(event, id) {
- var oldValue = (typeof id != 'undefined' && id.length > 0);
+ var oldValue = (typeof id != 'undefined' && (id.length > 0 || id > 0));
var checkAutocomplete = oldValue == true? false : true;
// check if the Value ist new
var isNewResult = isNew($(this).val(), checkAutocomplete);
- if(isNewResult[0] === true || isNewResult[1] != null) {
+ if(isNewResult[0] === true || (isNewResult[0] === false && typeof isNewResult[1] == 'string')) {
- if(oldValue == false && isNewResult[1] != null) {
+ if(oldValue == false && typeof isNewResult[1] == 'string') {
oldValue = true;
id = isNewResult[1];
}
if(options.allowAdd == true || oldValue) {
// Make a new tag in front the input
html = '<li class="tagedit-listelement tagedit-listelement-old">';
html += '<span dir="'+options.direction+'">' + $(this).val() + '</span>';
var name = oldValue? baseName + '['+id+options.addedPostfix+']' : baseName + '[]';
html += '<input type="hidden" name="'+name+'" value="'+$(this).val()+'" />';
html += '<a class="tagedit-close" title="'+options.texts.removeLinkTitle+'">x</a>';
html += '</li>';
$(this).parent().before(html);
}
}
$(this).val('');
// close autocomplete
if(options.autocompleteOptions.source) {
- $(this).autocomplete( "close" );
+ if($(this).is(':ui-autocomplete'))
+ $(this).autocomplete( "close" );
}
})
.keydown(function(event) {
var code = event.keyCode > 0? event.keyCode : event.which;
switch(code) {
case 8: // BACKSPACE
if($(this).val().length == 0) {
// delete Last Tag
var elementToRemove = elements.find('li.tagedit-listelement-old').last();
elementToRemove.fadeOut(options.animSpeed, function() {elementToRemove.remove();})
event.preventDefault();
return false;
}
break;
case 9: // TAB
if($(this).val().length > 0 && $('ul.ui-autocomplete #ui-active-menuitem').length == 0) {
$(this).trigger('transformToTag');
event.preventDefault();
return false;
}
break;
}
return true;
})
.keypress(function(event) {
var code = event.keyCode > 0? event.keyCode : event.which;
if($.inArray(code, options.breakKeyCodes) > -1) {
if($(this).val().length > 0 && $('ul.ui-autocomplete #ui-active-menuitem').length == 0) {
$(this).trigger('transformToTag');
}
event.preventDefault();
return false;
}
return true;
})
.bind('paste', function(e){
var that = $(this);
if (e.type == 'paste'){
setTimeout(function(){
that.trigger('transformToTag');
}, 1);
}
})
.blur(function() {
if($(this).val().length == 0) {
// disable the field to prevent sending with the form
$(this).attr('disabled', 'disabled').addClass('tagedit-input-disabled');
}
else {
// Delete entry after a timeout
var input = $(this);
$(this).data('blurtimer', window.setTimeout(function() {input.val('');}, 500));
}
})
.focus(function() {
window.clearTimeout($(this).data('blurtimer'));
});
if(options.autocompleteOptions.source != false) {
$(this).autocomplete(options.autocompleteOptions);
}
})
.end()
.click(function(event) {
switch(event.target.tagName) {
case 'A':
$(event.target).parent().fadeOut(options.animSpeed, function() {
$(event.target).parent().remove();
});
break;
case 'INPUT':
case 'SPAN':
case 'LI':
if($(event.target).hasClass('tagedit-listelement-deleted') == false &&
$(event.target).parent('li').hasClass('tagedit-listelement-deleted') == false) {
// Don't edit an deleted Items
return doEdit(event);
}
default:
$(this).find('#tagedit-input')
.removeAttr('disabled')
.removeClass('tagedit-input-disabled')
.focus();
}
return false;
})
- // forward focus event
+ // forward focus event (on tabbing through the form)
.focus(function(e){ $(this).click(); })
}
/**
* Sets all Actions and events for editing an Existing Tag.
*
* @param event {object} The original Event that was given
* return {boolean}
*/
function doEdit(event) {
if(options.allowEdit == false) {
// Do nothing
return;
}
var element = event.target.tagName == 'SPAN'? $(event.target).parent() : $(event.target);
var closeTimer = null;
// Event that is fired if the User finishes the edit of a tag
element.bind('finishEdit', function(event, doReset) {
window.clearTimeout(closeTimer);
var textfield = $(this).find(':text');
var isNewResult = isNew(textfield.val(), true);
if(textfield.val().length > 0 && (typeof doReset == 'undefined' || doReset === false) && (isNewResult[0] == true)) {
// This is a new Value and we do not want to do a reset. Set the new value
$(this).find(':hidden').val(textfield.val());
$(this).find('span').html(textfield.val());
}
textfield.remove();
- $(this).find('a.tagedit-save, a.tagedit-break, a.tagedit-delete, tester').remove(); // Workaround. This normaly has to be done by autogrow Plugin
+ $(this).find('a.tagedit-save, a.tagedit-break, a.tagedit-delete').remove(); // Workaround. This normaly has to be done by autogrow Plugin
$(this).removeClass('tagedit-listelement-edit').unbind('finishEdit');
return false;
});
var hidden = element.find(':hidden');
html = '<input type="text" name="tmpinput" autocomplete="off" value="'+hidden.val()+'" class="tagedit-edit-input" dir="'+options.direction+'"/>';
html += '<a class="tagedit-save" title="'+options.texts.saveEditLinkTitle+'">o</a>';
html += '<a class="tagedit-break" title="'+options.texts.breakEditLinkTitle+'">x</a>';
// If the Element is one from the Database, it can be deleted
if(options.allowDelete == true && element.find(':hidden').length > 0 &&
typeof element.find(':hidden').attr('name').match(baseNameRegexp)[3] != 'undefined') {
html += '<a class="tagedit-delete" title="'+options.texts.deleteLinkTitle+'">d</a>';
}
hidden.after(html);
element
.addClass('tagedit-listelement-edit')
.find('a.tagedit-save')
.click(function() {
$(this).parent().trigger('finishEdit');
return false;
})
.end()
.find('a.tagedit-break')
.click(function() {
$(this).parent().trigger('finishEdit', [true]);
return false;
})
.end()
.find('a.tagedit-delete')
.click(function() {
window.clearTimeout(closeTimer);
if(confirm(options.texts.deleteConfirmation)) {
- markAsDeleted($(this).parent());
+ var canDelete = checkToDelete($(this).parent());
+ if (!canDelete && confirm(options.texts.forceDeleteConfirmation)) {
+ markAsDeleted($(this).parent());
+ }
+
+ if(canDelete) {
+ markAsDeleted($(this).parent());
+ }
+
+ $(this).parent().find(':text').trigger('finishEdit', [true]);
}
else {
$(this).parent().find(':text').trigger('finishEdit', [true]);
}
return false;
})
.end()
.find(':text')
.focus()
.autoGrowInput({comfortZone: 10, minWidth: 15, maxWidth: 20000})
.keypress(function(event) {
switch(event.keyCode) {
case 13: // RETURN
event.preventDefault();
$(this).parent().trigger('finishEdit');
return false;
case 27: // ESC
event.preventDefault();
$(this).parent().trigger('finishEdit', [true]);
return false;
}
return true;
})
.blur(function() {
var that = $(this);
closeTimer = window.setTimeout(function() {that.parent().trigger('finishEdit', [true])}, 500);
});
}
+ /**
+ * Verifies if the tag select to be deleted is used by other records using an Ajax request.
+ *
+ * @param element
+ * @returns {boolean}
+ */
+ function checkToDelete(element) {
+ // if no URL is provide will not verify
+ if(options.checkToDeleteURL === null) {
+ return false;
+ }
+
+ var inputName = element.find('input:hidden').attr('name');
+ var idPattern = new RegExp('\\d');
+ var tagId = inputName.match(idPattern);
+ var checkResult = false;
+
+ $.ajax({
+ async : false,
+ url : options.checkToDeleteURL,
+ dataType: 'json',
+ type : 'POST',
+ data : { 'tagId' : tagId},
+ complete: function (XMLHttpRequest, textStatus) {
+
+ // Expected JSON Object: { "success": Boolean, "allowDelete": Boolean}
+ var result = $.parseJSON(XMLHttpRequest.responseText);
+ if(result.success === true){
+ checkResult = result.allowDelete;
+ }
+ }
+ });
+
+ return checkResult;
+ }
+
/**
* Marks a single Tag as deleted.
*
* @param element {object}
*/
function markAsDeleted(element) {
element
.trigger('finishEdit', [true])
.addClass('tagedit-listelement-deleted')
.attr('title', options.deletedElementTitle);
element.find(':hidden').each(function() {
var nameEndRegexp = new RegExp('('+options.addedPostfix+'|'+options.deletedPostfix+')?\]');
var name = $(this).attr('name').replace(nameEndRegexp, options.deletedPostfix+']');
$(this).attr('name', name);
});
}
/**
* Checks if a tag is already choosen.
*
* @param value {string}
* @param checkAutocomplete {boolean} optional Check also the autocomplet values
* @returns {Array} First item is a boolean, telling if the item should be put to the list, second is optional the ID from autocomplete list
*/
function isNew(value, checkAutocomplete) {
checkAutocomplete = typeof checkAutocomplete == 'undefined'? false : checkAutocomplete;
var autoCompleteId = null;
var compareValue = options.checkNewEntriesCaseSensitive == true? value : value.toLowerCase();
var isNew = true;
elements.find('li.tagedit-listelement-old input:hidden').each(function() {
var elementValue = options.checkNewEntriesCaseSensitive == true? $(this).val() : $(this).val().toLowerCase();
if(elementValue == compareValue) {
isNew = false;
}
});
if (isNew == true && checkAutocomplete == true && options.autocompleteOptions.source != false) {
var result = [];
if ($.isArray(options.autocompleteOptions.source)) {
result = options.autocompleteOptions.source;
}
else if ($.isFunction(options.autocompleteOptions.source)) {
options.autocompleteOptions.source({term: value}, function (data) {result = data});
}
else if (typeof options.autocompleteOptions.source === "string") {
// Check also autocomplete values
var autocompleteURL = options.autocompleteOptions.source;
if (autocompleteURL.match(/\?/)) {
autocompleteURL += '&';
} else {
autocompleteURL += '?';
}
autocompleteURL += 'term=' + value;
$.ajax({
async: false,
url: autocompleteURL,
dataType: 'json',
complete: function (XMLHttpRequest, textStatus) {
result = $.parseJSON(XMLHttpRequest.responseText);
}
});
}
-
+
// If there is an entry for that already in the autocomplete, don't use it (Check could be case sensitive or not)
for (var i = 0; i < result.length; i++) {
- var label = typeof result[i] == 'string' ? result[i] : result[i].label;
- if (options.checkNewEntriesCaseSensitive == false)
- label = label.toLowerCase();
+ var resultValue = result[i].label? result[i].label : result[i];
+ var label = options.checkNewEntriesCaseSensitive == true? resultValue : resultValue.toLowerCase();
if (label == compareValue) {
isNew = false;
autoCompleteId = typeof result[i] == 'string' ? i : result[i].id;
break;
}
}
}
return new Array(isNew, autoCompleteId);
}
}
})(jQuery);
(function($){
// jQuery autoGrowInput plugin by James Padolsey
// See related thread: http://stackoverflow.com/questions/931207/is-there-a-jquery-autogrow-plugin-for-text-fields
$.fn.autoGrowInput = function(o) {
-
- o = $.extend({
- maxWidth: 1000,
- minWidth: 0,
- comfortZone: 70
- }, o);
-
- this.filter('input:text').each(function(){
-
- var minWidth = o.minWidth || $(this).width(),
- val = '',
- input = $(this),
- testSubject = $('<tester/>').css({
- position: 'absolute',
- top: -9999,
- left: -9999,
- width: 'auto',
- fontSize: input.css('fontSize'),
- fontFamily: input.css('fontFamily'),
- fontWeight: input.css('fontWeight'),
- letterSpacing: input.css('letterSpacing'),
- whiteSpace: 'nowrap'
- }),
- check = function() {
-
- if (val === (val = input.val())) {return;}
-
- // Enter new content into testSubject
- var escaped = val.replace(/&/g, '&amp;').replace(/\s/g,'&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
- testSubject.html(escaped);
-
- // Calculate new width + whether to change
- var testerWidth = testSubject.width(),
- newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
- currentWidth = input.width(),
- isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
- || (newWidth > minWidth && newWidth < o.maxWidth);
-
- // Animate width
- if (isValidWidthChange) {
- input.width(newWidth);
- }
-
- };
-
- testSubject.insertAfter(input);
-
- $(this).bind('keyup keydown blur update', check);
-
- check();
- });
-
- return this;
+
+ o = $.extend({
+ maxWidth: 1000,
+ minWidth: 0,
+ comfortZone: 70
+ }, o);
+
+ this.filter('input:text').each(function(){
+
+ var minWidth = o.minWidth || $(this).width(),
+ val = '',
+ input = $(this),
+ testSubject = $('<tester/>').css({
+ position: 'absolute',
+ top: -9999,
+ left: -9999,
+ width: 'auto',
+ fontSize: input.css('fontSize'),
+ fontFamily: input.css('fontFamily'),
+ fontWeight: input.css('fontWeight'),
+ letterSpacing: input.css('letterSpacing'),
+ whiteSpace: 'nowrap'
+ }),
+ check = function() {
+
+ if (val === (val = input.val())) {return;}
+
+ // Enter new content into testSubject
+ var escaped = val.replace(/&/g, '&amp;').replace(/\s/g,'&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+ testSubject.html(escaped);
+
+ // Calculate new width + whether to change
+ var testerWidth = testSubject.width(),
+ newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
+ currentWidth = input.width(),
+ isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
+ || (newWidth > minWidth && newWidth < o.maxWidth);
+
+ // Animate width
+ if (isValidWidthChange) {
+ input.width(newWidth);
+ }
+
+ };
+
+ testSubject.insertAfter(input);
+
+ $(this).bind('keyup keydown blur update', check);
+
+ check();
+ });
+
+ return this;
};
-})(jQuery);
+})(jQuery);
\ No newline at end of file
diff --git a/plugins/tasklist/skins/larry/tagedit.css b/plugins/tasklist/skins/larry/tagedit.css
new file mode 100644
index 00000000..0ce32221
--- /dev/null
+++ b/plugins/tasklist/skins/larry/tagedit.css
@@ -0,0 +1,108 @@
+/**
+ * Styles of the tagedit inputsforms
+ */
+.tagedit-list {
+ width: 100%;
+ margin: 0;
+ padding: 4px 4px 0 5px;
+ overflow: auto;
+ min-height: 26px;
+ background: #fff;
+ border: 1px solid #b2b2b2;
+ border-radius: 4px;
+ box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
+ -moz-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
+ -webkit-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
+ -o-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
+}
+.tagedit-list li.tagedit-listelement {
+ list-style-type: none;
+ float: left;
+ margin: 0 4px 4px 0;
+ padding: 0;
+}
+
+/* New Item input */
+.tagedit-list li.tagedit-listelement-new input {
+ border: 0;
+ height: 100%;
+ padding: 4px 1px;
+ width: 15px;
+ background: #fff;
+ border-radius: 0;
+ box-shadow: none;
+ -moz-box-shadow: none;
+ -webkit-box-shadow: none;
+ -o-box-shadow: none;
+}
+.tagedit-list li.tagedit-listelement-new input:focus {
+ box-shadow: none;
+ -moz-box-shadow: none;
+ -webkit-box-shadow: none;
+ -o-box-shadow: none;
+ outline: none;
+}
+.tagedit-list li.tagedit-listelement-new input.tagedit-input-disabled {
+ display: none;
+}
+
+/* Item that is put to the List */
+.tagedit span.tag-element,
+.tagedit-list li.tagedit-listelement-old {
+ padding: 3px 0 1px 6px;
+ background: #ddeef5;
+ background: -moz-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#edf6fa), color-stop(100%,#d6e9f3));
+ background: -o-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
+ background: -ms-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
+ background: linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
+ border: 1px solid #c2dae5;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
+ color: #0d5165;
+}
+
+.tagedit span.tag-element {
+ margin-right: 0.6em;
+ padding: 2px 6px;
+/* cursor: pointer; */
+}
+
+.tagedit span.tag-element.inherit {
+ color: #666;
+ background: #f2f2f2;
+ border-color: #ddd;
+}
+
+.tagedit-list li.tagedit-listelement-old a.tagedit-close,
+.tagedit-list li.tagedit-listelement-old a.tagedit-break,
+.tagedit-list li.tagedit-listelement-old a.tagedit-delete,
+.tagedit-list li.tagedit-listelement-old a.tagedit-save {
+ text-indent: -2000px;
+ display: inline-block;
+ position: relative;
+ top: -1px;
+ width: 16px;
+ height: 16px;
+ margin: 0 2px 0 6px;
+ background: url('data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAAgUlEQVQoz2NgQAKzdxwWAOIEIG5AwiC+AAM2AJQIAOL3QPwfCwaJB6BrSMChGB0nwDQYwATP3nn4f+Ge4ygKQXyQOJKYAUjTepjAm09fwBimEUTDxJA0rWdANxWmaMXB0xiGwDADurthGkEAmwbqaCLFeWQFBOlBTlbkkp2MSE2wAA8R50rWvqeRAAAAAElFTkSuQmCC') left 1px no-repeat;
+ cursor: pointer;
+}
+
+/** Special hacks for IE7 **/
+
+html.ie7 .tagedit span.tag-element,
+html.ie7 .tagedit-list li.tagedit-listelement-old {
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#edf6fa', endColorstr='#d6e9f3', GradientType=0);
+}
+
+html.ie7 .tagedit-list li.tagedit-listelement span {
+ position: relative;
+ top: -3px;
+}
+
+html.ie7 .tagedit-list li.tagedit-listelement-old a.tagedit-close {
+ left: 5px;
+}
+
diff --git a/plugins/tasklist/skins/larry/tasklist.css b/plugins/tasklist/skins/larry/tasklist.css
index e3adcb22..14776e15 100644
--- a/plugins/tasklist/skins/larry/tasklist.css
+++ b/plugins/tasklist/skins/larry/tasklist.css
@@ -1,942 +1,835 @@
/**
* Roundcube Taklist plugin styles for skin "Larry"
*
* Copyright (C) 2012, Kolab Systems AG <contact@kolabsys.com>
* Screendesign by FLINT / Büro für Gestaltung, bueroflint.com
*
* The contents are subject to the Creative Commons Attribution-ShareAlike
* License. It is allowed to copy, distribute, transmit and to adapt the work
* by keeping credits to the original autors in the README file.
* See http://creativecommons.org/licenses/by-sa/3.0/ for details.
*/
#taskbar a.button-tasklist span.button-inner {
background-image: url(buttons.png);
background-position: 0 0;
}
#taskbar a.button-tasklist:hover span.button-inner,
#taskbar a.button-tasklist.button-selected span.button-inner {
background-position: 0 -26px;
}
ul.toolbarmenu li span.icon.taskadd {
background-image: url(buttons.png);
background-position: -4px -90px;
}
div.uidialog {
display: none;
}
body.attachmentwin #mainscreen {
top: 60px;
}
body.attachmentwin #topnav .topright {
margin-top: 20px;
}
#sidebar {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 240px;
}
.tasklistview #searchmenulink {
width: 15px;
}
#tagsbox {
position: absolute;
top: 42px;
left: 0;
width: 100%;
height: 242px;
}
#tasklistsbox {
position: absolute;
top: 300px;
left: 0;
width: 100%;
bottom: 0px;
}
#taskselector {
margin: -4px 40px 0 0;
padding: 0;
}
#taskselector li {
display: inline-block;
position: relative;
font-size: 90%;
padding-right: 0.3em;
}
#tagslist li,
#taskselector li a {
display: inline-block;
color: #004458;
min-width: 4em;
padding: 0.2em 0.6em 0.3em 0.6em;
text-align: center;
text-decoration: none;
border: 1px solid #eee;
border-color: transparent;
}
#taskselector li:first-child {
border-top: 0;
border-radius: 4px 4px 0 0;
}
#taskselector li:last-child {
border-bottom: 0;
border-radius: 0 0 4px 4px;
}
#taskselector li.overdue a {
color: #b72a2a;
font-weight: bold;
}
#taskselector li.inactive a {
color: #97b3bf;
}
#tagslist li.selected,
#taskselector li.selected a {
color: #fff;
background: #005d76;
background: -moz-linear-gradient(top, #005d76 0%, #004558 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#005d76), color-stop(100%,#004558));
background: -o-linear-gradient(top, #005d76 0%, #004558 100%);
background: -ms-linear-gradient(top, #005d76 0%, #004558 100%);
background: linear-gradient(top, #005d76 0%, #004558 100%);
box-shadow: inset 0 1px 1px 0 #003645;
-o-box-shadow: inset 0 1px 1px 0 #003645;
-webkit-box-shadow: inset 0 1px 1px 0 #003645;
-moz-box-shadow: inset 0 1px 1px 0 #003645;
border-color: #003645;
border-radius: 9px;
text-shadow: none;
outline: none;
}
#taskselector li .count {
display: none;
position: absolute;
top: -18px;
right: 5px;
min-width: 1.8em;
padding: 2px 4px;
background: #004558;
background: -moz-linear-gradient(top, #005d76 0%, #004558 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#005d76), color-stop(100%,#004558));
background: -o-linear-gradient(top, #005d76 0%, #004558 100%);
background: -ms-linear-gradient(top, #005d76 0%, #004558 100%);
background: linear-gradient(top, #005d76 0%, #004558 100%);
box-shadow: 0 1px 2px 0 rgba(24,24,24,0.6);
color: #fff;
border-radius: 3px;
text-align: center;
font-weight: bold;
font-size: 80%;
text-shadow: none;
}
#taskselector li .count:after {
content: "";
position: absolute;
bottom: -5px;
left: 50%;
margin-left: -5px;
border-style: solid;
border-width: 5px 5px 0;
border-color: #004558 transparent;
/* reduce the damage in FF3.0 */
display: block;
width: 0;
}
#taskselector li.overdue .count {
background: #ff3800;
}
#taskselector li.overdue .count:after {
border-color: #ff3800 transparent;
}
#tagslist {
padding: 0;
margin: 6px;
list-style: none;
}
#tagslist li {
display: inline-block;
color: #004458;
padding-right: 0.2em;
margin-right: 0.3em;
margin-bottom: 0.4em;
min-width: 1.2em;
cursor: pointer;
}
#tagslist li.inactive {
color: #89b3be;
padding-right: 0.6em;
font-size: 80%;
/* display: none; */
}
#tagslist li .count {
position: relative;
top: -1px;
margin-left: 5px;
padding: 0.15em 0.5em;
font-size: 80%;
font-weight: bold;
color: #59838e;
background: #c7e3ef;
box-shadow: inset 0 1px 1px 0 #b0ccd7;
-o-box-shadow: inset 0 1px 1px 0 #b0ccd7;
-webkit-box-shadow: inset 0 1px 1px 0 #b0ccd7;
-moz-box-shadow: inset 0 1px 1px 0 #b0ccd7;
border-color: #b0ccd7;
border-radius: 8px;
}
.tag-draghelper .tag .count,
#tagslist li.inactive .count {
display: none;
}
#tasklists li {
margin: 0;
height: 20px;
padding: 6px 8px 2px 6px;
display: block;
position: relative;
white-space: nowrap;
}
#tasklists li.virtual {
height: 12px;
}
#tasklists li label {
display: block;
}
#tasklists li span.listname {
display: block;
position: absolute;
top: 7px;
left: 26px;
right: 26px;
cursor: default;
padding-bottom: 2px;
padding-right: 30px;
color: #004458;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background: url(sprites.png) right 20px no-repeat;
}
#tasklists li span.handle {
display: inline-block;
width: 16px;
height: 16px;
margin-right: 4px;
background: url(sprites.png) -200px 0 no-repeat;
cursor: pointer;
}
#tasklists li:hover span.handle {
background-position: -20px -101px;
}
#tasklists li.focusview span.handle {
background-position: -2px -101px;
}
#tasklists li.selected span.listname {
font-weight: bold;
}
#tasklists li.readonly span.listname {
background-position: right -142px;
}
#tasklists li.other span.listname {
background-position: right -160px;
}
#tasklists li.other.readonly span.listname {
background-position: right -178px;
}
#tasklists li.shared span.listname {
background-position: right -196px;
}
#tasklists li.shared.readonly span.listname {
background-position: right -214px;
}
#tasklists li.virtual span.listname {
color: #aaa;
top: 2px;
}
#tasklists li.virtual span.handle {
background: none;
cursor: default;
}
#tasklists li input {
position: absolute;
top: 5px;
right: 5px;
}
#mainview-right {
position: absolute;
top: 0;
left: 256px;
right: 0;
bottom: 0;
}
#taskstoolbar {
position: absolute;
top: -6px;
left: 0;
width: 100%;
height: 40px;
white-space: nowrap;
}
#taskstoolbar a.button.newtask {
background-image: url(buttons.png);
background-position: center -53px;
}
#quickaddbox {
position: absolute;
top: 2px;
left: 0;
width: 60%;
height: 32px;
white-space: nowrap;
}
#quickaddinput {
width: 85%;
margin: 0;
padding: 3px 8px;
height: 18px;
background: #f1f1f1;
background: rgba(255, 255, 255, 0.7);
border-color: #a3a3a3;
font-weight: bold;
}
#quickaddbox .button {
margin-left: 5px;
padding: 3px 10px;
font-weight: bold;
}
#tasksview {
position: absolute;
top: 42px;
left: 0;
right: 0;
bottom: 0;
padding-bottom: 28px;
background: rgba(255, 255, 255, 0.2);
overflow: visible;
}
#message.statusbar {
border-top: 1px solid #c3c3c3;
}
#tasksview .scroller {
position: absolute;
left: 0;
top: 35px;
width: 100%;
bottom: 0;
overflow: auto;
}
#tasksview .buttonbar {
color: #777;
background: #eee;
background: -moz-linear-gradient(top, #eee 0%, #dfdfdf 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eee), color-stop(100%,#dfdfdf));
background: -o-linear-gradient(top, #eee 0%, #dfdfdf 100%);
background: -ms-linear-gradient(top, #eee 0%, #dfdfdf 100%);
background: linear-gradient(top, #eee 0%, #dfdfdf 100%);
border-bottom: 1px solid #ccc;
position: relative;
}
#tasksview .buttonbar .buttonbar-right {
position: absolute;
top: 6px;
right: 8px;
}
.buttonbar-right .listmenu {
display: inline-block;
cursor: pointer;
}
.buttonbar-right .listmenu .inner {
display: inline-block;
height: 18px;
width: 20px;
padding: 0;
background: url(sprites.png) 0 -237px no-repeat;
text-indent: -5000px;
}
#thelist {
padding: 0;
margin: 1em;
list-style: none;
}
#listmessagebox {
display: none;
font-size: 14px;
color: #666;
margin: 1.5em;
text-shadow: 0px 1px 1px #fff;
text-align:center;
}
.taskitem {
position: relative;
display: block;
margin-bottom: 3px;
}
.taskitem.dragging {
opacity: 0.5;
}
.taskitem .childtasks {
position: relative;
padding: 0;
margin: 3px 0 0 20px;
list-style: none;
}
.taskitem .childtoggle {
display: none;
position: absolute;
top: 4px;
left: -5px;
padding: 2px;
font-size: 10px;
color: #727272;
cursor: pointer;
width: 14px;
height: 14px;
background: url(sprites.png) -2px -80px no-repeat;
text-indent: -1000px;
overflow: hidden;
}
.taskitem .childtoggle.collapsed {
background-position: -18px -81px;
}
.taskhead {
position: relative;
margin-left: 14px;
padding: 4px 5px 3px 5px;
border: 1px solid #fff;
border-radius: 5px;
background: #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba(50, 50, 50, 0.5);
-moz-box-shadow: 0 1px 1px 0 rgba(50, 50, 50, 0.5);
box-shadow: 0 1px 1px 0 rgba(50, 50, 50, 0.5);
padding-right: 26em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: default;
}
.taskhead.droptarget {
border-color: #4787b1;
box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-moz-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-webkit-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-o-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
}
.taskhead .complete {
margin: -1px 1em 0 0;
}
.taskhead .title {
font-size: 12px;
}
.taskhead .flagged {
display: inline-block;
visibility: hidden;
width: 16px;
height: 16px;
background: url(sprites.png) -2px -3px no-repeat;
margin: -3px 1em 0 0;
vertical-align: middle;
cursor: pointer;
}
.taskhead:hover .flagged {
visibility: visible;
}
.taskhead.flagged .flagged {
visibility: visible;
background-position: -2px -23px;
}
.taskhead .tags {
display: block;
position: absolute;
top: 3px;
right: 10em;
max-width: 14em;
height: 16px;
overflow: hidden;
padding-top: 1px;
text-align: right;
}
.tag-draghelper .tag,
.taskhead .tags .tag {
font-size: 85%;
background: #d9ecf4;
border: 1px solid #c2dae5;
border-radius: 4px;
padding: 1px 7px;
margin-right: 3px;
}
.tag-draghelper li.tag {
list-style: none;
font-size: 100%;
}
.taskhead .date {
position: absolute;
top: 4px;
right: 30px;
text-align: right;
cursor: pointer;
}
.taskhead.nodate .date {
color: #ddd;
}
.taskhead.overdue .date {
color: #d00;
}
.taskhead.nodate:hover .date {
color: #999;
}
.taskhead .date input {
padding: 1px 2px;
border: 1px solid #ddd;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
outline: none;
text-align: right;
width: 6em;
font-size: 11px;
}
.taskhead .actions,
.taskhead .delete {
display: block;
visibility: hidden;
position: absolute;
top: 3px;
right: 6px;
width: 18px;
height: 18px;
background: url(sprites.png) 0 -80px no-repeat;
text-indent: -1000px;
overflow: hidden;
cursor: pointer;
}
.taskhead .delete {
background-position: 0 -40px;
}
.taskhead:hover .actions,
.taskhead:hover .delete {
visibility: visible;
}
.taskhead.complete {
opacity: 0.6;
}
.taskhead.complete .title {
text-decoration: line-through;
}
.taskhead .progressbar {
position: absolute;
bottom: 1px;
left: 6px;
right: 6px;
height: 2px;
}
.taskhead.complete .progressbar {
display: none;
}
.taskhead .progressvalue {
height: 1px;
background: rgba(1, 124, 180, 0.2);
border-top: 1px solid #219de6;
}
ul.toolbarmenu li span.add,
ul.toolbarmenu li span.expand,
ul.toolbarmenu li span.collapse {
background-image: url(sprites.png);
}
ul.toolbarmenu li span.add {
background-position: 0 -302px;
}
ul.toolbarmenu li span.expand {
background-position: 0 -258px;
}
ul.toolbarmenu li span.collapse {
background-position: 0 -280px;
}
ul.toolbarmenu li span.delete {
background-position: 0 -1508px;
}
.taskitem-draghelper {
/*
width: 32px;
height: 26px;
*/
background: #444;
border: 1px solid #555;
border-radius: 4px;
box-shadow: 0 2px 6px 0 #333;
-moz-box-shadow: 0 2px 6px 0 #333;
-webkit-box-shadow: 0 2px 6px 0 #333;
-o-box-shadow: 0 2px 6px 0 #333;
z-index: 5000;
padding: 2px 10px;
font-size: 20px;
color: #ccc;
opacity: 0.92;
filter: alpha(opacity=90);
text-shadow: 0px 1px 1px #333;
}
#rootdroppable {
display: none;
position: absolute;
top: 36px;
left: 1em;
right: 1em;
height: 5px;
background: #ddd;
border-radius: 3px;
}
#rootdroppable.droptarget {
background: #4787b1;
box-shadow: 0 0 2px 1px rgba(71,135,177, 0.9);
-moz-box-shadow: 0 0 2px 1px rgba(71,135,177, 0.9);
-webkit-box-shadow: 0 0 2px 1px rgba(71,135,177, 0.9);
-o-box-shadow: 0 0 2px 1px rgba(71,135,177, 0.9);
}
/*** task edit form ***/
#taskedit,
#taskshow {
display:none;
}
#taskedit {
position: relative;
top: -1.5em;
padding: 0.5em 0.1em;
margin: 0 -0.2em;
}
#taskshow h2 {
margin-top: -0.5em;
}
#taskshow label {
color: #999;
}
#task-parent-title {
position: relative;
top: -0.6em;
}
a.morelink {
font-size: 90%;
color: #0069a6;
text-decoration: none;
outline: none;
}
a.morelink:hover {
text-decoration: underline;
}
#taskedit .ui-tabs-panel {
min-height: 24em;
}
#taskeditform input.text,
#taskeditform textarea {
width: 97%;
}
#taskeditform .formbuttons {
margin: 0.5em 0;
}
#taskedit-attachments {
margin: 0.6em 0;
}
#taskedit-attachments ul li {
display: block;
color: #333;
font-weight: bold;
padding: 8px 4px 3px 30px;
text-shadow: 0px 1px 1px #fff;
text-decoration: none;
white-space: nowrap;
}
#taskedit-attachments ul li a.file {
padding: 0;
}
#taskedit-attachments-form {
margin-top: 1em;
padding-top: 0.8em;
border-top: 2px solid #fafafa;
}
div.form-section {
position: relative;
margin-top: 0.2em;
margin-bottom: 0.8em;
}
.form-section label {
display: inline-block;
min-width: 7em;
padding-right: 0.5em;
margin-bottom: 0.3em;
}
label.block {
display: block;
margin-bottom: 0.3em;
}
#taskedit-completeness-slider {
display: inline-block;
margin-left: 2em;
width: 30em;
height: 0.8em;
border: 1px solid #ccc;
}
#taskedit-tagline {
width: 97%;
}
#taskedit .droptarget {
background-image: url(../../../../skins/larry/images/filedrop.png) !important;
background-position: center bottom !important;
background-repeat: no-repeat !important;
}
#taskedit .droptarget.hover,
#taskedit .droptarget.active {
border-color: #019bc6;
box-shadow: 0 0 3px 2px rgba(71,135,177, 0.5);
-moz-box-shadow: 0 0 3px 2px rgba(71,135,177, 0.5);
-webkit-box-shadow: 0 0 3px 2px rgba(71,135,177, 0.5);
-o-box-shadow: 0 0 3px 2px rgba(71,135,177, 0.5);
}
#taskedit .droptarget.hover {
background-color: #d9ecf4;
box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-moz-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-webkit-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
-o-box-shadow: 0 0 5px 2px rgba(71,135,177, 0.9);
}
#task-attachments .attachmentslist li {
float: left;
margin-right: 1em;
}
#task-attachments .attachmentslist li a {
outline: none;
}
-/**
- * Styles of the tagedit inputsforms
- */
-.tagedit-list {
- width: 100%;
- margin: 0;
- padding: 4px 4px 0 5px;
- overflow: auto;
- min-height: 26px;
- background: #fff;
- border: 1px solid #b2b2b2;
- border-radius: 4px;
- box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
- -moz-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
- -webkit-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
- -o-box-shadow: inset 0 0 2px 1px rgba(0,0,0, 0.1);
-}
-.tagedit-list li.tagedit-listelement {
- list-style-type: none;
- float: left;
- margin: 0 4px 4px 0;
- padding: 0;
-}
-
-/* New Item input */
-.tagedit-list li.tagedit-listelement-new input {
- border: 0;
- height: 100%;
- padding: 4px 1px;
- width: 15px;
- background: #fff;
- border-radius: 0;
- box-shadow: none;
- -moz-box-shadow: none;
- -webkit-box-shadow: none;
- -o-box-shadow: none;
-}
-.tagedit-list li.tagedit-listelement-new input:focus {
- box-shadow: none;
- -moz-box-shadow: none;
- -webkit-box-shadow: none;
- -o-box-shadow: none;
- outline: none;
-}
-.tagedit-list li.tagedit-listelement-new input.tagedit-input-disabled {
- display: none;
-}
-
-/* Item that is put to the List */
-.form-section span.tag-element,
-.tagedit-list li.tagedit-listelement-old {
- padding: 3px 0 1px 6px;
- background: #ddeef5;
- background: -moz-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#edf6fa), color-stop(100%,#d6e9f3));
- background: -o-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
- background: -ms-linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
- background: linear-gradient(top, #edf6fa 0%, #d6e9f3 100%);
- border: 1px solid #c2dae5;
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- border-radius: 4px;
- color: #0d5165;
-}
-
-.form-section span.tag-element {
- margin-right: 0.6em;
- padding: 2px 6px;
-/* cursor: pointer; */
-}
-
-.form-section span.tag-element.inherit {
- color: #666;
- background: #f2f2f2;
- border-color: #ddd;
-}
-
-.tagedit-list li.tagedit-listelement-old a.tagedit-close,
-.tagedit-list li.tagedit-listelement-old a.tagedit-break,
-.tagedit-list li.tagedit-listelement-old a.tagedit-delete,
-.tagedit-list li.tagedit-listelement-old a.tagedit-save {
- text-indent: -2000px;
- display: inline-block;
- position: relative;
- top: -1px;
- width: 16px;
- height: 16px;
- margin: 0 2px 0 6px;
- background: url(sprites.png) -2px -122px no-repeat;
- cursor: pointer;
-}
-
-
/** Special hacks for IE7 **/
/** They need to be in this file to also affect the task-create dialog embedded in mail view **/
html.ie7 #taskedit-completeness-slider {
display: inline;
}
-html.ie7 .form-section span.tag-element,
-html.ie7 .tagedit-list li.tagedit-listelement-old {
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#edf6fa', endColorstr='#d6e9f3', GradientType=0);
-}
-
-html.ie7 .tagedit-list li.tagedit-listelement span {
- position: relative;
- top: -3px;
-}
-
-html.ie7 .tagedit-list li.tagedit-listelement-old a.tagedit-close {
- left: 5px;
-}
-
diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php
index 1eaacbd1..ca677447 100644
--- a/plugins/tasklist/tasklist.php
+++ b/plugins/tasklist/tasklist.php
@@ -1,976 +1,974 @@
<?php
/**
* Tasks plugin for Roundcube webmail
*
* @version @package_version@
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* Copyright (C) 2012, Kolab Systems AG <contact@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class tasklist extends rcube_plugin
{
const FILTER_MASK_TODAY = 1;
const FILTER_MASK_TOMORROW = 2;
const FILTER_MASK_WEEK = 4;
const FILTER_MASK_LATER = 8;
const FILTER_MASK_NODATE = 16;
const FILTER_MASK_OVERDUE = 32;
const FILTER_MASK_FLAGGED = 64;
const FILTER_MASK_COMPLETE = 128;
const SESSION_KEY = 'tasklist_temp';
public static $filter_masks = array(
'today' => self::FILTER_MASK_TODAY,
'tomorrow' => self::FILTER_MASK_TOMORROW,
'week' => self::FILTER_MASK_WEEK,
'later' => self::FILTER_MASK_LATER,
'nodate' => self::FILTER_MASK_NODATE,
'overdue' => self::FILTER_MASK_OVERDUE,
'flagged' => self::FILTER_MASK_FLAGGED,
'complete' => self::FILTER_MASK_COMPLETE,
);
public $task = '?(?!login|logout).*';
public $rc;
public $lib;
public $driver;
public $timezone;
public $ui;
private $collapsed_tasks = array();
/**
* Plugin initialization.
*/
function init()
{
$this->require_plugin('libcalendaring');
$this->rc = rcube::get_instance();
$this->lib = libcalendaring::get_instance();
$this->register_task('tasks', 'tasklist');
// load plugin configuration
$this->load_config();
$this->timezone = $this->lib->timezone;
// proceed initialization in startup hook
$this->add_hook('startup', array($this, 'startup'));
}
/**
* Startup hook
*/
public function startup($args)
{
// the tasks module can be enabled/disabled by the kolab_auth plugin
if ($this->rc->config->get('tasklist_disabled', false) || !$this->rc->config->get('tasklist_enabled', true))
return;
// load localizations
$this->add_texts('localization/', $args['task'] == 'tasks' && (!$args['action'] || $args['action'] == 'print'));
$this->rc->load_language($_SESSION['language'], array('tasks.tasks' => $this->gettext('navtitle'))); // add label for task title
if ($args['task'] == 'tasks' && $args['action'] != 'save-pref') {
$this->load_driver();
// register calendar actions
$this->register_action('index', array($this, 'tasklist_view'));
$this->register_action('task', array($this, 'task_action'));
$this->register_action('tasklist', array($this, 'tasklist_action'));
$this->register_action('counts', array($this, 'fetch_counts'));
$this->register_action('fetch', array($this, 'fetch_tasks'));
$this->register_action('inlineui', array($this, 'get_inline_ui'));
$this->register_action('mail2task', array($this, 'mail_message2task'));
$this->register_action('get-attachment', array($this, 'attachment_get'));
$this->register_action('upload', array($this, 'attachment_upload'));
$this->add_hook('refresh', array($this, 'refresh'));
$this->collapsed_tasks = array_filter(explode(',', $this->rc->config->get('tasklist_collapsed_tasks', '')));
}
else if ($args['task'] == 'mail') {
// TODO: register hooks to catch ical/vtodo email attachments
if ($args['action'] == 'show' || $args['action'] == 'preview') {
// $this->add_hook('message_load', array($this, 'mail_message_load'));
// $this->add_hook('template_object_messagebody', array($this, 'mail_messagebody_html'));
}
// add 'Create event' item to message menu
if ($this->api->output->type == 'html') {
$this->api->add_content(html::tag('li', null,
$this->api->output->button(array(
'command' => 'tasklist-create-from-mail',
'label' => 'tasklist.createfrommail',
'type' => 'link',
'classact' => 'icon taskaddlink active',
'class' => 'icon taskaddlink',
'innerclass' => 'icon taskadd',
))),
'messagemenu');
$this->api->output->add_label('tasklist.createfrommail');
}
}
if (!$this->rc->output->ajax_call && !$this->rc->output->env['framed']) {
require_once($this->home . '/tasklist_ui.php');
$this->ui = new tasklist_ui($this);
$this->ui->init();
}
// add hooks for alarms handling
$this->add_hook('pending_alarms', array($this, 'pending_alarms'));
$this->add_hook('dismiss_alarms', array($this, 'dismiss_alarms'));
}
/**
* Helper method to load the backend driver according to local config
*/
private function load_driver()
{
if (is_object($this->driver))
return;
$driver_name = $this->rc->config->get('tasklist_driver', 'database');
$driver_class = 'tasklist_' . $driver_name . '_driver';
require_once($this->home . '/drivers/tasklist_driver.php');
require_once($this->home . '/drivers/' . $driver_name . '/' . $driver_class . '.php');
switch ($driver_name) {
case "kolab":
$this->require_plugin('libkolab');
default:
$this->driver = new $driver_class($this);
break;
}
$this->rc->output->set_env('tasklist_driver', $driver_name);
}
/**
* Dispatcher for task-related actions initiated by the client
*/
public function task_action()
{
$filter = intval(get_input_value('filter', RCUBE_INPUT_GPC));
$action = get_input_value('action', RCUBE_INPUT_GPC);
$rec = get_input_value('t', RCUBE_INPUT_POST, true);
$oldrec = $rec;
$success = $refresh = false;
switch ($action) {
case 'new':
$oldrec = null;
$rec = $this->prepare_task($rec);
$rec['uid'] = $this->generate_uid();
$temp_id = $rec['tempid'];
if ($success = $this->driver->create_task($rec)) {
$refresh = $this->driver->get_task($rec);
if ($temp_id) $refresh['tempid'] = $temp_id;
$this->cleanup_task($rec);
}
break;
case 'edit':
$rec = $this->prepare_task($rec);
if ($success = $this->driver->edit_task($rec)) {
$refresh[] = $this->driver->get_task($rec);
$this->cleanup_task($rec);
// move all childs if list assignment was changed
if (!empty($rec['_fromlist']) && !empty($rec['list']) && $rec['_fromlist'] != $rec['list']) {
foreach ($this->driver->get_childs(array('id' => $rec['id'], 'list' => $rec['_fromlist']), true) as $cid) {
$child = array('id' => $cid, 'list' => $rec['list'], '_fromlist' => $rec['_fromlist']);
if ($this->driver->move_task($child)) {
$r = $this->driver->get_task($child);
if ((bool)($filter & self::FILTER_MASK_COMPLETE) == ($r['complete'] == 1.0)) {
$refresh[] = $r;
}
}
}
}
}
break;
case 'move':
foreach ((array)$rec['id'] as $id) {
$r = $rec;
$r['id'] = $id;
if ($this->driver->move_task($r)) {
$refresh[] = $this->driver->get_task($r);
$success = true;
// move all childs, too
foreach ($this->driver->get_childs(array('id' => $rec['id'], 'list' => $rec['_fromlist']), true) as $cid) {
$child = $rec;
$child['id'] = $cid;
if ($this->driver->move_task($child)) {
$r = $this->driver->get_task($child);
if ((bool)($filter & self::FILTER_MASK_COMPLETE) == ($r['complete'] == 1.0)) {
$refresh[] = $r;
}
}
}
}
}
break;
case 'delete':
$mode = intval(get_input_value('mode', RCUBE_INPUT_POST));
$oldrec = $this->driver->get_task($rec);
if ($success = $this->driver->delete_task($rec, false)) {
// delete/modify all childs
foreach ($this->driver->get_childs($rec, $mode) as $cid) {
$child = array('id' => $cid, 'list' => $rec['list']);
if ($mode == 1) { // delete all childs
if ($this->driver->delete_task($child, false)) {
if ($this->driver->undelete)
$_SESSION['tasklist_undelete'][$rec['id']][] = $cid;
}
else
$success = false;
}
else {
$child['parent_id'] = strval($oldrec['parent_id']);
$this->driver->edit_task($child);
}
}
// update parent task to adjust list of children
if (!empty($oldrec['parent_id'])) {
$refresh[] = $this->driver->get_task(array('id' => $oldrec['parent_id'], 'list' => $rec['list']));
}
}
if (!$success)
$this->rc->output->command('plugin.reload_data');
break;
case 'undelete':
if ($success = $this->driver->undelete_task($rec)) {
$refresh[] = $this->driver->get_task($rec);
foreach ((array)$_SESSION['tasklist_undelete'][$rec['id']] as $cid) {
if ($this->driver->undelete_task($rec)) {
$refresh[] = $this->driver->get_task($rec);
}
}
}
break;
case 'collapse':
foreach (explode(',', $rec['id']) as $rec_id) {
if (intval(get_input_value('collapsed', RCUBE_INPUT_GPC))) {
$this->collapsed_tasks[] = $rec_id;
}
else {
$i = array_search($rec_id, $this->collapsed_tasks);
if ($i !== false)
unset($this->collapsed_tasks[$i]);
}
}
$this->rc->user->save_prefs(array('tasklist_collapsed_tasks' => join(',', array_unique($this->collapsed_tasks))));
return; // avoid further actions
}
if ($success) {
$this->rc->output->show_message('successfullysaved', 'confirmation');
$this->update_counts($oldrec, $refresh);
}
else
$this->rc->output->show_message('tasklist.errorsaving', 'error');
// unlock client
$this->rc->output->command('plugin.unlock_saving');
if ($refresh) {
if ($refresh['id']) {
$this->encode_task($refresh);
}
else if (is_array($refresh)) {
foreach ($refresh as $i => $r)
$this->encode_task($refresh[$i]);
}
$this->rc->output->command('plugin.update_task', $refresh);
}
}
/**
* repares new/edited task properties before save
*/
private function prepare_task($rec)
{
// try to be smart and extract date from raw input
if ($rec['raw']) {
foreach (array('today','tomorrow','sunday','monday','tuesday','wednesday','thursday','friday','saturday','sun','mon','tue','wed','thu','fri','sat') as $word) {
$locwords[] = '/^' . preg_quote(mb_strtolower($this->gettext($word))) . '\b/i';
$normwords[] = $word;
$datewords[] = $word;
}
foreach (array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','now','dec') as $month) {
$locwords[] = '/(' . preg_quote(mb_strtolower($this->gettext('long'.$month))) . '|' . preg_quote(mb_strtolower($this->gettext($month))) . ')\b/i';
$normwords[] = $month;
$datewords[] = $month;
}
foreach (array('on','this','next','at') as $word) {
$fillwords[] = preg_quote(mb_strtolower($this->gettext($word)));
$fillwords[] = $word;
}
$raw = trim($rec['raw']);
$date_str = '';
// translate localized keywords
$raw = preg_replace('/^(' . join('|', $fillwords) . ')\s*/i', '', $raw);
$raw = preg_replace($locwords, $normwords, $raw);
// find date pattern
$date_pattern = '!^(\d+[./-]\s*)?((?:\d+[./-])|' . join('|', $datewords) . ')\.?(\s+\d{4})?[:;,]?\s+!i';
if (preg_match($date_pattern, $raw, $m)) {
$date_str .= $m[1] . $m[2] . $m[3];
$raw = preg_replace(array($date_pattern, '/^(' . join('|', $fillwords) . ')\s*/i'), '', $raw);
// add year to date string
if ($m[1] && !$m[3])
$date_str .= date('Y');
}
// find time pattern
$time_pattern = '/^(\d+([:.]\d+)?(\s*[hapm.]+)?),?\s+/i';
if (preg_match($time_pattern, $raw, $m)) {
$has_time = true;
$date_str .= ($date_str ? ' ' : 'today ') . $m[1];
$raw = preg_replace($time_pattern, '', $raw);
}
// yes, raw input matched a (valid) date
if (strlen($date_str) && strtotime($date_str) && ($date = new DateTime($date_str, $this->timezone))) {
$rec['date'] = $date->format('Y-m-d');
if ($has_time)
$rec['time'] = $date->format('H:i');
$rec['title'] = $raw;
}
else
$rec['title'] = $rec['raw'];
}
// normalize input from client
if (isset($rec['complete'])) {
$rec['complete'] = floatval($rec['complete']);
if ($rec['complete'] > 1)
$rec['complete'] /= 100;
}
if (isset($rec['flagged']))
$rec['flagged'] = intval($rec['flagged']);
// fix for garbage input
if ($rec['description'] == 'null')
$rec['description'] = '';
foreach ($rec as $key => $val) {
if ($val === 'null')
$rec[$key] = null;
}
if (!empty($rec['date'])) {
$this->normalize_dates($rec, 'date', 'time');
}
if (!empty($rec['startdate'])) {
$this->normalize_dates($rec, 'startdate', 'starttime');
}
// convert tags to array, filter out empty entries
if (isset($rec['tags']) && !is_array($rec['tags'])) {
$rec['tags'] = array_filter((array)$rec['tags']);
}
// alarms cannot work without a date
if ($rec['alarms'] && !$rec['date'] && !$rec['startdate'] && strpos($rec['alarms'], '@') === false)
$rec['alarms'] = '';
$attachments = array();
$taskid = $rec['id'];
if (is_array($_SESSION[self::SESSION_KEY]) && $_SESSION[self::SESSION_KEY]['id'] == $taskid) {
if (!empty($_SESSION[self::SESSION_KEY]['attachments'])) {
foreach ($_SESSION[self::SESSION_KEY]['attachments'] as $id => $attachment) {
if (is_array($rec['attachments']) && in_array($id, $rec['attachments'])) {
$attachments[$id] = $this->rc->plugins->exec_hook('attachment_get', $attachment);
unset($attachments[$id]['abort'], $attachments[$id]['group']);
}
}
}
}
$rec['attachments'] = $attachments;
if (is_numeric($rec['id']) && $rec['id'] < 0)
unset($rec['id']);
return $rec;
}
/**
* Utility method to convert a tasks date/time values into a normalized format
*/
private function normalize_dates(&$rec, $date_key, $time_key)
{
try {
// parse date from user format (#2801)
$date_format = $this->rc->config->get(empty($rec[$time_key]) ? 'date_format' : 'date_long', 'Y-m-d');
$date = DateTime::createFromFormat($date_format, trim($rec[$date_key] . ' ' . $rec[$time_key]), $this->timezone);
// fall back to default strtotime logic
if (empty($date)) {
$date = new DateTime($rec[$date_key] . ' ' . $rec[$time_key], $this->timezone);
}
$rec[$date_key] = $date->format('Y-m-d');
if (!empty($rec[$time_key]))
$rec[$time_key] = $date->format('H:i');
return true;
}
catch (Exception $e) {
$rec[$date_key] = $rec[$time_key] = null;
}
return false;
}
/**
* Releases some resources after successful save
*/
private function cleanup_task(&$rec)
{
// remove temp. attachment files
if (!empty($_SESSION[self::SESSION_KEY]) && ($taskid = $_SESSION[self::SESSION_KEY]['id'])) {
$this->rc->plugins->exec_hook('attachments_cleanup', array('group' => $taskid));
$this->rc->session->remove(self::SESSION_KEY);
}
}
/**
* Dispatcher for tasklist actions initiated by the client
*/
public function tasklist_action()
{
$action = get_input_value('action', RCUBE_INPUT_GPC);
$list = get_input_value('l', RCUBE_INPUT_POST, true);
$success = false;
if (isset($list['showalarms']))
$list['showalarms'] = intval($list['showalarms']);
switch ($action) {
case 'new':
$list += array('showalarms' => true, 'active' => true, 'editable' => true);
if ($insert_id = $this->driver->create_list($list)) {
$list['id'] = $insert_id;
$this->rc->output->command('plugin.insert_tasklist', $list);
$success = true;
}
break;
case 'edit':
if ($newid = $this->driver->edit_list($list)) {
$list['oldid'] = $list['id'];
$list['id'] = $newid;
$this->rc->output->command('plugin.update_tasklist', $list);
$success = true;
}
break;
case 'subscribe':
$success = $this->driver->subscribe_list($list);
break;
case 'remove':
if (($success = $this->driver->remove_list($list)))
$this->rc->output->command('plugin.destroy_tasklist', $list);
break;
}
if ($success)
$this->rc->output->show_message('successfullysaved', 'confirmation');
else
$this->rc->output->show_message('tasklist.errorsaving', 'error');
$this->rc->output->command('plugin.unlock_saving');
}
/**
* Get counts for active tasks divided into different selectors
*/
public function fetch_counts()
{
if (isset($_REQUEST['lists'])) {
$lists = get_input_value('lists', RCUBE_INPUT_GPC);
}
else {
foreach ($this->driver->get_lists() as $list) {
if ($list['active'])
$lists[] = $list['id'];
}
}
$counts = $this->driver->count_tasks($lists);
$this->rc->output->command('plugin.update_counts', $counts);
}
/**
* Adjust the cached counts after changing a task
*/
public function update_counts($oldrec, $newrec)
{
// rebuild counts until this function is finally implemented
$this->fetch_counts();
// $this->rc->output->command('plugin.update_counts', $counts);
}
/**
*
*/
public function fetch_tasks()
{
$f = intval(get_input_value('filter', RCUBE_INPUT_GPC));
$search = get_input_value('q', RCUBE_INPUT_GPC);
$filter = array('mask' => $f, 'search' => $search);
$lists = get_input_value('lists', RCUBE_INPUT_GPC);;
/*
// convert magic date filters into a real date range
switch ($f) {
case self::FILTER_MASK_TODAY:
$today = new DateTime('now', $this->timezone);
$filter['from'] = $filter['to'] = $today->format('Y-m-d');
break;
case self::FILTER_MASK_TOMORROW:
$tomorrow = new DateTime('now + 1 day', $this->timezone);
$filter['from'] = $filter['to'] = $tomorrow->format('Y-m-d');
break;
case self::FILTER_MASK_OVERDUE:
$yesterday = new DateTime('yesterday', $this->timezone);
$filter['to'] = $yesterday->format('Y-m-d');
break;
case self::FILTER_MASK_WEEK:
$today = new DateTime('now', $this->timezone);
$filter['from'] = $today->format('Y-m-d');
$weekend = new DateTime('now + 7 days', $this->timezone);
$filter['to'] = $weekend->format('Y-m-d');
break;
case self::FILTER_MASK_LATER:
$date = new DateTime('now + 8 days', $this->timezone);
$filter['from'] = $date->format('Y-m-d');
break;
}
*/
$data = $this->tasks_data($this->driver->list_tasks($filter, $lists), $f, $tags);
$this->rc->output->command('plugin.data_ready', array('filter' => $f, 'lists' => $lists, 'search' => $search, 'data' => $data, 'tags' => array_values(array_unique($tags))));
}
/**
* Prepare and sort the given task records to be sent to the client
*/
private function tasks_data($records, $f, &$tags)
{
$data = $tags = $this->task_tree = $this->task_titles = array();
foreach ($records as $rec) {
if ($rec['parent_id']) {
$this->task_tree[$rec['id']] = $rec['parent_id'];
}
$this->encode_task($rec);
if (!empty($rec['tags']))
$tags = array_merge($tags, (array)$rec['tags']);
// apply filter; don't trust the driver on this :-)
if ((!$f && $rec['complete'] < 1.0) || ($rec['mask'] & $f))
$data[] = $rec;
}
// sort tasks according to their hierarchy level and due date
array_walk($data, array($this, 'task_walk_tree'));
usort($data, array($this, 'task_sort_cmp'));
return $data;
}
/**
* Prepare the given task record before sending it to the client
*/
private function encode_task(&$rec)
{
$rec['mask'] = $this->filter_mask($rec);
$rec['flagged'] = intval($rec['flagged']);
$rec['complete'] = floatval($rec['complete']);
$rec['changed'] = is_object($rec['changed']) ? $rec['changed']->format('U') : null;
if ($rec['date']) {
try {
$date = new DateTime($rec['date'] . ' ' . $rec['time'], $this->timezone);
$rec['datetime'] = intval($date->format('U'));
$rec['date'] = $date->format($this->rc->config->get('date_format', 'Y-m-d'));
$rec['_hasdate'] = 1;
}
catch (Exception $e) {
$rec['date'] = $rec['datetime'] = null;
}
}
else {
$rec['date'] = $rec['datetime'] = null;
$rec['_hasdate'] = 0;
}
if ($rec['startdate']) {
try {
$date = new DateTime($rec['startdate'] . ' ' . $rec['starttime'], $this->timezone);
$rec['startdatetime'] = intval($date->format('U'));
$rec['startdate'] = $date->format($this->rc->config->get('date_format', 'Y-m-d'));
}
catch (Exception $e) {
$rec['startdate'] = $rec['startdatetime'] = null;
}
}
if ($rec['alarms'])
$rec['alarms_text'] = libcalendaring::alarms_text($rec['alarms']);
foreach ((array)$rec['attachments'] as $k => $attachment) {
$rec['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
}
if (!is_array($rec['tags']))
$rec['tags'] = (array)$rec['tags'];
sort($rec['tags'], SORT_LOCALE_STRING);
if (in_array($rec['id'], $this->collapsed_tasks))
$rec['collapsed'] = true;
if (empty($rec['parent_id']))
$rec['parent_id'] = null;
$this->task_titles[$rec['id']] = $rec['title'];
}
/**
* Callback function for array_walk over all tasks.
* Sets tree depth and parent titles
*/
private function task_walk_tree(&$rec)
{
$rec['_depth'] = 0;
$parent_id = $this->task_tree[$rec['id']];
while ($parent_id) {
$rec['_depth']++;
$rec['parent_title'] = $this->task_titles[$parent_id];
$parent_id = $this->task_tree[$parent_id];
}
}
/**
* Compare function for task list sorting.
* Nested tasks need to be sorted to the end.
*/
private function task_sort_cmp($a, $b)
{
$d = $a['_depth'] - $b['_depth'];
if (!$d) $d = $b['_hasdate'] - $a['_hasdate'];
if (!$d) $d = $a['datetime'] - $b['datetime'];
return $d;
}
/**
* Compute the filter mask of the given task
*
* @param array Hash array with Task record properties
* @return int Filter mask
*/
public function filter_mask($rec)
{
static $today, $tomorrow, $weeklimit;
if (!$today) {
$today_date = new DateTime('now', $this->timezone);
$today = $today_date->format('Y-m-d');
$tomorrow_date = new DateTime('now + 1 day', $this->timezone);
$tomorrow = $tomorrow_date->format('Y-m-d');
$week_date = new DateTime('now + 7 days', $this->timezone);
$weeklimit = $week_date->format('Y-m-d');
}
$mask = 0;
$start = $rec['startdate'] ?: '1900-00-00';
$duedate = $rec['date'] ?: '3000-00-00';
if ($rec['flagged'])
$mask |= self::FILTER_MASK_FLAGGED;
if ($rec['complete'] == 1.0)
$mask |= self::FILTER_MASK_COMPLETE;
if (empty($rec['date']))
$mask |= self::FILTER_MASK_NODATE;
else if ($rec['date'] < $today)
$mask |= self::FILTER_MASK_OVERDUE;
if ($duedate <= $today || ($rec['startdate'] && $start <= $today))
$mask |= self::FILTER_MASK_TODAY;
if ($duedate <= $tomorrow || ($rec['startdate'] && $start <= $tomorrow))
$mask |= self::FILTER_MASK_TOMORROW;
if ($start > $tomorrow || ($duedate > $tomorrow && $duedate <= $weeklimit))
$mask |= self::FILTER_MASK_WEEK;
if ($start > $weeklimit || ($rec['date'] && $duedate > $weeklimit))
$mask |= self::FILTER_MASK_LATER;
return $mask;
}
/******* UI functions ********/
/**
* Render main view of the tasklist task
*/
public function tasklist_view()
{
$this->ui->init();
$this->ui->init_templates();
$this->rc->output->set_pagetitle($this->gettext('navtitle'));
$this->rc->output->send('tasklist.mainview');
}
/**
*
*/
public function get_inline_ui()
{
foreach (array('save','cancel','savingdata') as $label)
$texts['tasklist.'.$label] = $this->gettext($label);
$texts['tasklist.newtask'] = $this->gettext('createfrommail');
$this->ui->init_templates();
echo $this->api->output->parse('tasklist.taskedit', false, false);
+ echo html::tag('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $this->url($this->local_skin_path() . '/tagedit.css'), 'nl' => true));
echo html::tag('script', array('type' => 'text/javascript'),
"rcmail.set_env('tasklists', " . json_encode($this->api->output->env['tasklists']) . ");\n".
-// "rcmail.set_env('deleteicon', '" . $this->api->output->env['deleteicon'] . "');\n".
-// "rcmail.set_env('cancelicon', '" . $this->api->output->env['cancelicon'] . "');\n".
-// "rcmail.set_env('loadingicon', '" . $this->api->output->env['loadingicon'] . "');\n".
"rcmail.add_label(" . json_encode($texts) . ");\n"
);
exit;
}
/**
* Handler for keep-alive requests
* This will check for updated data in active lists and sync them to the client
*/
public function refresh($attr)
{
// refresh the entire list every 10th time to also sync deleted items
if (rand(0,10) == 10) {
$this->rc->output->command('plugin.reload_data');
return;
}
$filter = array(
'since' => $attr['last'],
'search' => get_input_value('q', RCUBE_INPUT_GPC),
'mask' => intval(get_input_value('filter', RCUBE_INPUT_GPC)) & self::FILTER_MASK_COMPLETE,
);
$lists = get_input_value('lists', RCUBE_INPUT_GPC);;
$updates = $this->driver->list_tasks($filter, $lists);
if (!empty($updates)) {
$this->rc->output->command('plugin.refresh_tasks', $this->tasks_data($updates, 255, $tags), true);
// update counts
$counts = $this->driver->count_tasks($lists);
$this->rc->output->command('plugin.update_counts', $counts);
}
}
/**
* Handler for pending_alarms plugin hook triggered by the calendar module on keep-alive requests.
* This will check for pending notifications and pass them to the client
*/
public function pending_alarms($p)
{
$this->load_driver();
if ($alarms = $this->driver->pending_alarms($p['time'] ?: time())) {
foreach ($alarms as $alarm) {
// encode alarm object to suit the expectations of the calendaring code
if ($alarm['date'])
$alarm['start'] = new DateTime($alarm['date'].' '.$alarm['time'], $this->timezone);
$alarm['id'] = 'task:' . $alarm['id']; // prefix ID with task:
$alarm['allday'] = empty($alarm['time']) ? 1 : 0;
$p['alarms'][] = $alarm;
}
}
return $p;
}
/**
* Handler for alarm dismiss hook triggered by the calendar module
*/
public function dismiss_alarms($p)
{
$this->load_driver();
foreach ((array)$p['ids'] as $id) {
if (strpos($id, 'task:') === 0)
$p['success'] |= $this->driver->dismiss_alarm(substr($id, 5), $p['snooze']);
}
return $p;
}
/******* Attachment handling *******/
/**
* Handler for attachments upload
*/
public function attachment_upload()
{
$this->lib->attachment_upload(self::SESSION_KEY);
}
/**
* Handler for attachments download/displaying
*/
public function attachment_get()
{
// show loading page
if (!empty($_GET['_preload'])) {
return $this->lib->attachment_loading_page();
}
$task = get_input_value('_t', RCUBE_INPUT_GPC);
$list = get_input_value('_list', RCUBE_INPUT_GPC);
$id = get_input_value('_id', RCUBE_INPUT_GPC);
$task = array('id' => $task, 'list' => $list);
$attachment = $this->driver->get_attachment($id, $task);
// show part page
if (!empty($_GET['_frame'])) {
$this->lib->attachment = $attachment;
$this->register_handler('plugin.attachmentframe', array($this->lib, 'attachment_frame'));
$this->register_handler('plugin.attachmentcontrols', array($this->lib, 'attachment_header'));
$this->rc->output->send('tasklist.attachment');
}
// deliver attachment content
else if ($attachment) {
$attachment['body'] = $this->driver->get_attachment_body($id, $task);
$this->lib->attachment_get($attachment);
}
// if we arrive here, the requested part was not found
header('HTTP/1.1 404 Not Found');
exit;
}
/******* Email related function *******/
public function mail_message2task()
{
$uid = get_input_value('_uid', RCUBE_INPUT_POST);
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
$task = array();
// establish imap connection
$imap = $this->rc->get_storage();
$imap->set_mailbox($mbox);
$message = new rcube_message($uid);
if ($message->headers) {
$task['title'] = trim($message->subject);
$task['description'] = trim($message->first_text_part());
$task['id'] = -$uid;
$this->load_driver();
// copy mail attachments to task
if ($message->attachments && $this->driver->attachments) {
if (!is_array($_SESSION[self::SESSION_KEY]) || $_SESSION[self::SESSION_KEY]['id'] != $task['id']) {
$_SESSION[self::SESSION_KEY] = array();
$_SESSION[self::SESSION_KEY]['id'] = $task['id'];
$_SESSION[self::SESSION_KEY]['attachments'] = array();
}
foreach ((array)$message->attachments as $part) {
$attachment = array(
'data' => $imap->get_message_part($uid, $part->mime_id, $part),
'size' => $part->size,
'name' => $part->filename,
'mimetype' => $part->mimetype,
'group' => $task['id'],
);
$attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
if ($attachment['status'] && !$attachment['abort']) {
$id = $attachment['id'];
$attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
// store new attachment in session
unset($attachment['status'], $attachment['abort'], $attachment['data']);
$_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment;
$attachment['id'] = 'rcmfile' . $attachment['id']; // add prefix to consider it 'new'
$task['attachments'][] = $attachment;
}
}
}
$this->rc->output->command('plugin.mail2taskdialog', $task);
}
else {
$this->rc->output->command('display_message', $this->gettext('messageopenerror'), 'error');
}
$this->rc->output->send();
}
/******* Utility functions *******/
/**
* Generate a unique identifier for an event
*/
public function generate_uid()
{
return strtoupper(md5(time() . uniqid(rand())) . '-' . substr(md5($this->rc->user->get_username()), 0, 16));
}
}
diff --git a/plugins/tasklist/tasklist_ui.php b/plugins/tasklist/tasklist_ui.php
index 21faba3e..8d3c371d 100644
--- a/plugins/tasklist/tasklist_ui.php
+++ b/plugins/tasklist/tasklist_ui.php
@@ -1,287 +1,289 @@
<?php
/**
* User Interface class for the Tasklist plugin
*
* @version @package_version@
* @author Thomas Bruederli <bruederli@kolabsys.com>
*
* Copyright (C) 2012, Kolab Systems AG <contact@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class tasklist_ui
{
private $rc;
private $plugin;
private $ready = false;
function __construct($plugin)
{
$this->plugin = $plugin;
$this->rc = $plugin->rc;
}
/**
* Calendar UI initialization and requests handlers
*/
public function init()
{
if ($this->ready) // already done
return;
// add taskbar button
$this->plugin->add_button(array(
'command' => 'tasks',
'class' => 'button-tasklist',
'classsel' => 'button-tasklist button-selected',
'innerclass' => 'button-inner',
'label' => 'tasklist.navtitle',
), 'taskbar');
$this->plugin->include_stylesheet($this->plugin->local_skin_path() . '/tasklist.css');
$this->plugin->include_script('tasklist_base.js');
// copy config to client
// $this->rc->output->set_env('tasklist_settings', $settings);
$this->ready = true;
}
/**
* Register handler methods for the template engine
*/
public function init_templates()
{
$this->plugin->register_handler('plugin.tasklists', array($this, 'tasklists'));
$this->plugin->register_handler('plugin.tasklist_select', array($this, 'tasklist_select'));
$this->plugin->register_handler('plugin.category_select', array($this, 'category_select'));
$this->plugin->register_handler('plugin.searchform', array($this->rc->output, 'search_form'));
$this->plugin->register_handler('plugin.quickaddform', array($this, 'quickadd_form'));
$this->plugin->register_handler('plugin.tasklist_editform', array($this, 'tasklist_editform'));
$this->plugin->register_handler('plugin.tasks', array($this, 'tasks_resultview'));
$this->plugin->register_handler('plugin.tagslist', array($this, 'tagslist'));
$this->plugin->register_handler('plugin.tags_editline', array($this, 'tags_editline'));
$this->plugin->register_handler('plugin.alarm_select', array($this, 'alarm_select'));
$this->plugin->register_handler('plugin.attachments_form', array($this, 'attachments_form'));
$this->plugin->register_handler('plugin.attachments_list', array($this, 'attachments_list'));
$this->plugin->register_handler('plugin.filedroparea', array($this, 'file_drop_area'));
$this->plugin->include_script('jquery.tagedit.js');
$this->plugin->include_script('tasklist.js');
+
+ $this->plugin->include_stylesheet($this->plugin->local_skin_path() . '/tagedit.css');
}
/**
*
*/
function tasklists($attrib = array())
{
$lists = $this->plugin->driver->get_lists();
$li = '';
foreach ((array)$lists as $id => $prop) {
if ($attrib['activeonly'] && !$prop['active'])
continue;
unset($prop['user_id']);
$prop['alarms'] = $this->plugin->driver->alarms;
$prop['undelete'] = $this->plugin->driver->undelete;
$prop['sortable'] = $this->plugin->driver->sortable;
$prop['attachments'] = $this->plugin->driver->attachments;
if (!$prop['virtual'])
$jsenv[$id] = $prop;
$html_id = html_identifier($id);
$class = 'tasks-' . asciiwords($id, true);
$title = $prop['name'] != $prop['listname'] ? html_entity_decode($prop['name'], ENT_COMPAT, RCMAIL_CHARSET) : '';
if ($prop['virtual'])
$class .= ' virtual';
else if (!$prop['editable'])
$class .= ' readonly';
if ($prop['class_name'])
$class .= ' '.$prop['class_name'];
$li .= html::tag('li', array('id' => 'rcmlitasklist' . $html_id, 'class' => $class),
($prop['virtual'] ? '' : html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active']))) .
html::span(array('class' => 'handle', 'title' => $this->plugin->gettext('focusview')), '&nbsp;') .
html::span(array('class' => 'listname', 'title' => $title), $prop['listname']));
}
$this->rc->output->set_env('tasklists', $jsenv);
$this->rc->output->add_gui_object('folderlist', $attrib['id']);
return html::tag('ul', $attrib, $li, html::$common_attrib);
}
/**
* Render a HTML select box for list selection
*/
function tasklist_select($attrib = array())
{
$attrib['name'] = 'list';
$attrib['is_escaped'] = true;
$select = new html_select($attrib);
foreach ((array)$this->plugin->driver->get_lists() as $id => $prop) {
if ($prop['editable'])
$select->add($prop['name'], $id);
}
return $select->show(null);
}
function tasklist_editform($attrib = array())
{
$fields = array(
'name' => array(
'id' => 'taskedit-tasklistame',
'label' => $this->plugin->gettext('listname'),
'value' => html::tag('input', array('id' => 'taskedit-tasklistame', 'name' => 'name', 'type' => 'text', 'class' => 'text', 'size' => 40)),
),
/*
'color' => array(
'id' => 'taskedit-color',
'label' => $this->plugin->gettext('color'),
'value' => html::tag('input', array('id' => 'taskedit-color', 'name' => 'color', 'type' => 'text', 'class' => 'text colorpicker', 'size' => 6)),
),
*/
'showalarms' => array(
'id' => 'taskedit-showalarms',
'label' => $this->plugin->gettext('showalarms'),
'value' => html::tag('input', array('id' => 'taskedit-showalarms', 'name' => 'color', 'type' => 'checkbox')),
),
);
return html::tag('form', array('action' => "#", 'method' => "post", 'id' => 'tasklisteditform'),
$this->plugin->driver->tasklist_edit_form($fields)
);
}
/**
* Render HTML form for alarm configuration
*/
function alarm_select($attrib = array())
{
return $this->plugin->lib->alarm_select($attrib, $this->plugin->driver->alarm_types, $this->plugin->driver->alarm_absolute);
}
/**
*
*/
function quickadd_form($attrib)
{
$attrib += array('action' => $this->rc->url('add'), 'method' => 'post', 'id' => 'quickaddform');
$input = new html_inputfield(array('name' => 'text', 'id' => 'quickaddinput'));
$button = html::tag('input', array('type' => 'submit', 'value' => '+', 'class' => 'button mainaction'));
$this->rc->output->add_gui_object('quickaddform', $attrib['id']);
return html::tag('form', $attrib, $input->show() . $button);
}
/**
* The result view
*/
function tasks_resultview($attrib)
{
$attrib += array('id' => 'rcmtaskslist');
$this->rc->output->add_gui_object('resultlist', $attrib['id']);
unset($attrib['name']);
return html::tag('ul', $attrib, '');
}
/**
* Container for a tags cloud
*/
function tagslist($attrib)
{
$attrib += array('id' => 'rcmtasktagslist');
unset($attrib['name']);
$this->rc->output->add_gui_object('tagslist', $attrib['id']);
return html::tag('ul', $attrib, '');
}
/**
* Interactive UI element to add/remove tags
*/
function tags_editline($attrib)
{
$attrib += array('id' => 'rcmtasktagsedit');
$this->rc->output->add_gui_object('edittagline', $attrib['id']);
$input = new html_inputfield(array('name' => 'tags[]', 'class' => 'tag', 'size' => $attrib['size'], 'tabindex' => $attrib['tabindex']));
return html::div($attrib, $input->show(''));
}
/**
* Generate HTML element for attachments list
*/
function attachments_list($attrib = array())
{
if (!$attrib['id'])
$attrib['id'] = 'rcmtaskattachmentlist';
$this->rc->output->add_gui_object('attachmentlist', $attrib['id']);
return html::tag('ul', $attrib, '', html::$common_attrib);
}
/**
* Generate the form for event attachments upload
*/
function attachments_form($attrib = array())
{
// add ID if not given
if (!$attrib['id'])
$attrib['id'] = 'rcmtaskuploadform';
// Get max filesize, enable upload progress bar
$max_filesize = rcube_upload_init();
$button = new html_inputfield(array('type' => 'button'));
$input = new html_inputfield(array(
'type' => 'file',
'name' => '_attachments[]',
'multiple' => 'multiple',
'size' => $attrib['attachmentfieldsize'],
));
return html::div($attrib,
html::div(null, $input->show()) .
html::div('formbuttons', $button->show(rcube_label('upload'), array('class' => 'button mainaction',
'onclick' => JS_OBJECT_NAME . ".upload_file(this.form)"))) .
html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))
);
}
/**
* Register UI object for HTML5 drag & drop file upload
*/
function file_drop_area($attrib = array())
{
if ($attrib['id']) {
$this->rc->output->add_gui_object('filedrop', $attrib['id']);
$this->rc->output->set_env('filedrop', array('action' => 'upload', 'fieldname' => '_attachments'));
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Apr 24, 11:01 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18855288
Default Alt Text
(92 KB)

Event Timeline