'+b.html+' '),d=a("#"+c).find("a").first();return d.click(e(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){b.preventDefault(),this.pending_destroy_click=!0;return this.choice_destroy(a(b.target))},b.prototype.choice_destroy=function(a){this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel"));return a.parents("li").first().remove()},b.prototype.result_select=function(){var a,b,c,d;if(this.result_highlight){a=this.result_highlight,b=a.attr("id"),this.result_clear_highlight(),a.addClass("result-selected"),this.is_multiple?this.result_deactivate(a):this.result_single_selected=a,d=b.substr(b.lastIndexOf("_")+1),c=this.results_data[d],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.is_multiple?this.choice_build(c):this.selected_item.find("span").first().text(c.text),this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change");return this.search_field_scale()}},b.prototype.result_activate=function(a){return a.addClass("active-result").show()},b.prototype.result_deactivate=function(a){return a.removeClass("active-result").hide()},b.prototype.result_deselect=function(b){var c,d;d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change");return this.search_field_scale()},b.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;j=new Date,this.no_results_clear(),h=0,i=this.search_field.val()===this.default_text?"":a("
").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o"+c.html.substr(k+i.length),l=l.substr(0,k)+""+l.substr(k)):l=c.html,a("#"+g).html!==l&&a("#"+g).html(l),this.result_activate(a("#"+g)),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).show()):(this.result_highlight&&g===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(a("#"+g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;dNo results match " "'),c.find("span").first().html(b);return this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight){a=this.result_highlight.prevAll("li.active-result");if(a.length)return this.result_do_highlight(a.first());this.choices>0&&this.results_hide();return this.result_clear_highlight()}},b.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClass("search-choice-focus")},b.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus");return this.pending_backstroke=null},b.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select();break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:break;default:return this.results_search()}},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i ",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height();return this.dropdown.css({top:b+"px"})}},b.prototype.generate_field_id=function(){var a;a=this.generate_random_id(),this.form_field.id=a;return a},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b.prototype.generate_random_char=function(){var a,b,c;a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length);return b=a.substring(c,c+1)};return b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}).call(this),function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html(''):b.html(''+this.default_text+'
'),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),!this.is_multiple&&this.form_field.options.length<=this.disable_search_threshold&&this.container.addClass("chzn-container-single-nosearch"),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build();return this.set_tab_index()},b.prototype.register_observers=function(){this.container.mousedown(e(function(a){return this.container_mousedown(a)},this)),this.container.mouseup(e(function(a){return this.container_mouseup(a)},this)),this.container.mouseenter(e(function(a){return this.mouse_enter(a)},this)),this.container.mouseleave(e(function(a){return this.mouse_leave(a)},this)),this.search_results.mouseup(e(function(a){return this.search_results_mouseup(a)},this)),this.search_results.mouseover(e(function(a){return this.search_results_mouseover(a)},this)),this.search_results.mouseout(e(function(a){return this.search_results_mouseout(a)},this)),this.form_field_jq.bind("liszt:updated",e(function(a){return this.results_update_field(a)},this)),this.search_field.blur(e(function(a){return this.input_blur(a)},this)),this.search_field.keyup(e(function(a){return this.keyup_checker(a)},this)),this.search_field.keydown(e(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.click(e(function(a){return this.choices_click(a)},this));return this.search_field.focus(e(function(a){return this.input_focus(a)},this))}},b.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq.attr("disabled");if(this.is_disabled){this.container.addClass("chzn-disabled"),this.search_field.attr("disabled",!0),this.is_multiple||this.selected_item.unbind("focus",this.activate_action);return this.close_field()}this.container.removeClass("chzn-disabled"),this.search_field.attr("disabled",!1);if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},b.prototype.container_mousedown=function(b){var c;if(!this.is_disabled){c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&b.stopPropagation();if(!this.pending_destroy_click&&!c){this.active_field?!this.is_multiple&&b&&(a(b.target)===this.selected_item||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1}},b.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},b.prototype.mouse_enter=function(){return this.mouse_on_container=!0},b.prototype.mouse_leave=function(){return this.mouse_on_container=!1},b.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(e(function(){return this.container_mousedown()},this),50)},b.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(e(function(){return this.blur_test()},this),100)}},b.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},b.prototype.close_field=function(){a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},b.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val());return this.search_field.focus()},b.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},b.prototype.results_build=function(){var a,b,c,e,f,g;c=new Date,this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||this.selected_item.find("span").text(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e')));this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(a);return this.parsing=!1},b.prototype.result_add_group=function(b){if(!b.disabled){b.dom_id=this.container_id+"_g_"+b.array_index;return''+a("
").text(b.label).html()+" "}return""},b.prototype.result_add_option=function(a){var b,c;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option"),a.classes!==""&&b.push(a.classes),c=a.style.cssText!==""?' style="'+a.style+'"':"";return'"+a.html+" "}return""},b.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},b.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+' '),d=a("#"+c).find("a").first();return d.click(e(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){b.preventDefault();if(!this.is_disabled){this.pending_destroy_click=!0;return this.choice_destroy(a(b.target))}return b.stopPropagation},b.prototype.choice_destroy=function(a){this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel"));return a.parents("li").first().remove()},b.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},b.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight){b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.selected_item.find("span").first().after(' ')),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change");return this.search_field_scale()}},b.prototype.result_activate=function(a){return a.addClass("active-result")},b.prototype.result_deactivate=function(a){return a.removeClass("active-result")},b.prototype.result_deselect=function(b){var c,d;d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change");return this.search_field_scale()},b.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;j=new Date,this.no_results_clear(),h=0,i=this.search_field.val()===this.default_text?"":a("
").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o"+c.html.substr(k+i.length),l=l.substr(0,k)+""+l.substr(k)):l=c.html,a("#"+g).html!==l&&a("#"+g).html(l),this.result_activate(a("#"+g)),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).show()):(this.result_highlight&&g===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(a("#"+g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d'+this.results_none_found+' " "'),c.find("span").first().html(b);return this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight){a=this.result_highlight.prevAll("li.active-result");if(a.length)return this.result_do_highlight(a.first());this.choices>0&&this.results_hide();return this.result_clear_highlight()}},b.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClass("search-choice-focus")},b.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus");return this.pending_backstroke=null},b.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i ",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height();return this.dropdown.css({top:b+"px"})}},b.prototype.generate_field_id=function(){var a;a=this.generate_random_id(),this.form_field.id=a;return a},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b.prototype.generate_random_char=function(){var a,b,c;a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length);return b=a.substring(c,c+1)};return b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}).call(this),function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d
+ * Location: http://github.com/tplaner/When
+ * Created: September 2010
+ * Description: Determines the next date of recursion given an iCalendar "rrule" like pattern.
+ * Requirements: PHP 5.3+ - makes extensive use of the Date and Time library (http://us2.php.net/manual/en/book.datetime.php)
+ */
+class When
+{
+ protected $frequency;
+
+ protected $start_date;
+ protected $try_date;
+
+ protected $end_date;
+
+ protected $gobymonth;
+ protected $bymonth;
+
+ protected $gobyweekno;
+ protected $byweekno;
+
+ protected $gobyyearday;
+ protected $byyearday;
+
+ protected $gobymonthday;
+ protected $bymonthday;
+
+ protected $gobyday;
+ protected $byday;
+
+ protected $gobysetpos;
+ protected $bysetpos;
+
+ protected $suggestions;
+
+ protected $count;
+ protected $counter;
+
+ protected $goenddate;
+
+ protected $interval;
+
+ protected $wkst;
+
+ protected $valid_week_days;
+ protected $valid_frequency;
+
+ /**
+ * __construct
+ */
+ public function __construct()
+ {
+ $this->frequency = null;
+
+ $this->gobymonth = false;
+ $this->bymonth = range(1,12);
+
+ $this->gobymonthday = false;
+ $this->bymonthday = range(1,31);
+
+ $this->gobyday = false;
+ // setup the valid week days (0 = sunday)
+ $this->byday = range(0,6);
+
+ $this->gobyyearday = false;
+ $this->byyearday = range(0,366);
+
+ $this->gobysetpos = false;
+ $this->bysetpos = range(1,366);
+
+ $this->gobyweekno = false;
+ // setup the range for valid weeks
+ $this->byweekno = range(0,54);
+
+ $this->suggestions = array();
+
+ // this will be set if a count() is specified
+ $this->count = 0;
+ // how many *valid* results we returned
+ $this->counter = 0;
+
+ // max date we'll return
+ $this->end_date = new DateTime('9999-12-31');
+
+ // the interval to increase the pattern by
+ $this->interval = 1;
+
+ // what day does the week start on? (0 = sunday)
+ $this->wkst = 0;
+
+ $this->valid_week_days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
+
+ $this->valid_frequency = array('SECONDLY', 'MINUTELY', 'HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY');
+ }
+
+ /**
+ * @param DateTime|string $start_date of the recursion - also is the first return value.
+ * @param string $frequency of the recrusion, valid frequencies: secondly, minutely, hourly, daily, weekly, monthly, yearly
+ */
+ public function recur($start_date, $frequency = "daily")
+ {
+ try
+ {
+ if(is_object($start_date))
+ {
+ $this->start_date = clone $start_date;
+ }
+ else
+ {
+ // timestamps within the RFC have a 'Z' at the end of them, remove this.
+ $start_date = trim($start_date, 'Z');
+ $this->start_date = new DateTime($start_date);
+ }
+
+ $this->try_date = clone $this->start_date;
+ }
+ catch(Exception $e)
+ {
+ throw new InvalidArgumentException('Invalid start date DateTime: ' . $e);
+ }
+
+ $this->freq($frequency);
+
+ return $this;
+ }
+
+ public function freq($frequency)
+ {
+ if(in_array(strtoupper($frequency), $this->valid_frequency))
+ {
+ $this->frequency = strtoupper($frequency);
+ }
+ else
+ {
+ throw new InvalidArgumentException('Invalid frequency type.');
+ }
+
+ return $this;
+ }
+
+ // accepts an rrule directly
+ public function rrule($rrule)
+ {
+ // strip off a trailing semi-colon
+ $rrule = trim($rrule, ";");
+
+ $parts = explode(";", $rrule);
+
+ foreach($parts as $part)
+ {
+ list($rule, $param) = explode("=", $part);
+
+ $rule = strtoupper($rule);
+ $param = strtoupper($param);
+
+ switch($rule)
+ {
+ case "FREQ":
+ $this->frequency = $param;
+ break;
+ case "UNTIL":
+ $this->until($param);
+ break;
+ case "COUNT":
+ $this->count($param);
+ break;
+ case "INTERVAL":
+ $this->interval($param);
+ break;
+ case "BYDAY":
+ $params = explode(",", $param);
+ $this->byday($params);
+ break;
+ case "BYMONTHDAY":
+ $params = explode(",", $param);
+ $this->bymonthday($params);
+ break;
+ case "BYYEARDAY":
+ $params = explode(",", $param);
+ $this->byyearday($params);
+ break;
+ case "BYWEEKNO":
+ $params = explode(",", $param);
+ $this->byweekno($params);
+ break;
+ case "BYMONTH":
+ $params = explode(",", $param);
+ $this->bymonth($params);
+ break;
+ case "BYSETPOS":
+ $params = explode(",", $param);
+ $this->bysetpos($params);
+ break;
+ case "WKST":
+ $this->wkst($param);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ //max number of items to return based on the pattern
+ public function count($count)
+ {
+ $this->count = (int)$count;
+
+ return $this;
+ }
+
+ // how often the recurrence rule repeats
+ public function interval($interval)
+ {
+ $this->interval = (int)$interval;
+
+ return $this;
+ }
+
+ // starting day of the week
+ public function wkst($day)
+ {
+ switch($day)
+ {
+ case 'SU':
+ $this->wkst = 0;
+ break;
+ case 'MO':
+ $this->wkst = 1;
+ break;
+ case 'TU':
+ $this->wkst = 2;
+ break;
+ case 'WE':
+ $this->wkst = 3;
+ break;
+ case 'TH':
+ $this->wkst = 4;
+ break;
+ case 'FR':
+ $this->wkst = 5;
+ break;
+ case 'SA':
+ $this->wkst = 6;
+ break;
+ }
+
+ return $this;
+ }
+
+ // max date
+ public function until($end_date)
+ {
+ try
+ {
+ if(is_object($end_date))
+ {
+ $this->end_date = clone $end_date;
+ }
+ else
+ {
+ // timestamps within the RFC have a 'Z' at the end of them, remove this.
+ $end_date = trim($end_date, 'Z');
+ $this->end_date = new DateTime($end_date);
+ }
+ }
+ catch(Exception $e)
+ {
+ throw new InvalidArgumentException('Invalid end date DateTime: ' . $e);
+ }
+
+ return $this;
+ }
+
+ public function bymonth($months)
+ {
+ if(is_array($months))
+ {
+ $this->gobymonth = true;
+ $this->bymonth = $months;
+ }
+
+ return $this;
+ }
+
+ public function bymonthday($days)
+ {
+ if(is_array($days))
+ {
+ $this->gobymonthday = true;
+ $this->bymonthday = $days;
+ }
+
+ return $this;
+ }
+
+ public function byweekno($weeks)
+ {
+ $this->gobyweekno = true;
+
+ if(is_array($weeks))
+ {
+ $this->byweekno = $weeks;
+ }
+
+ return $this;
+ }
+
+ public function bysetpos($days)
+ {
+ $this->gobysetpos = true;
+
+ if(is_array($days))
+ {
+ $this->bysetpos = $days;
+ }
+
+ return $this;
+ }
+
+ public function byday($days)
+ {
+ $this->gobyday = true;
+
+ if(is_array($days))
+ {
+ $this->byday = array();
+ foreach($days as $day)
+ {
+ $len = strlen($day);
+
+ $as = '+';
+
+ // 0 mean no occurence is set
+ $occ = 0;
+
+ if($len == 3)
+ {
+ $occ = substr($day, 0, 1);
+ }
+ if($len == 4)
+ {
+ $as = substr($day, 0, 1);
+ $occ = substr($day, 1, 1);
+ }
+
+ if($as == '-')
+ {
+ $occ = '-' . $occ;
+ }
+ else
+ {
+ $occ = '+' . $occ;
+ }
+
+ $day = substr($day, -2, 2);
+ switch($day)
+ {
+ case 'SU':
+ $this->byday[] = $occ . 'SU';
+ break;
+ case 'MO':
+ $this->byday[] = $occ . 'MO';
+ break;
+ case 'TU':
+ $this->byday[] = $occ . 'TU';
+ break;
+ case 'WE':
+ $this->byday[] = $occ . 'WE';
+ break;
+ case 'TH':
+ $this->byday[] = $occ . 'TH';
+ break;
+ case 'FR':
+ $this->byday[] = $occ . 'FR';
+ break;
+ case 'SA':
+ $this->byday[] = $occ . 'SA';
+ break;
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ public function byyearday($days)
+ {
+ $this->gobyyearday = true;
+
+ if(is_array($days))
+ {
+ $this->byyearday = $days;
+ }
+
+ return $this;
+ }
+
+ // this creates a basic list of dates to "try"
+ protected function create_suggestions()
+ {
+ switch($this->frequency)
+ {
+ case "YEARLY":
+ $interval = 'year';
+ break;
+ case "MONTHLY":
+ $interval = 'month';
+ break;
+ case "WEEKLY":
+ $interval = 'week';
+ break;
+ case "DAILY":
+ $interval = 'day';
+ break;
+ case "HOURLY":
+ $interval = 'hour';
+ break;
+ case "MINUTELY":
+ $interval = 'minute';
+ break;
+ case "SECONDLY":
+ $interval = 'second';
+ break;
+ }
+
+ $month_day = $this->try_date->format('j');
+ $month = $this->try_date->format('n');
+ $year = $this->try_date->format('Y');
+
+ $timestamp = $this->try_date->format('H:i:s');
+
+ if($this->gobysetpos)
+ {
+ if($this->try_date == $this->start_date)
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+ else
+ {
+ if($this->gobyday)
+ {
+ foreach($this->bysetpos as $_pos)
+ {
+ $tmp_array = array();
+ $_mdays = range(1, date('t',mktime(0,0,0,$month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $month . '-' . $_mday . ' ' . $timestamp);
+
+ $occur = ceil($_mday / 7);
+
+ $day_of_week = $date_time->format('l');
+ $dow_abr = strtoupper(substr($day_of_week, 0, 2));
+
+ // set the day of the month + (positive)
+ $occur = '+' . $occur . $dow_abr;
+ $occur_zero = '+0' . $dow_abr;
+
+ // set the day of the month - (negative)
+ $total_days = $date_time->format('t') - $date_time->format('j');
+ $occur_neg = '-' . ceil(($total_days + 1)/7) . $dow_abr;
+
+ $day_from_end_of_month = $date_time->format('t') + 1 - $_mday;
+
+ if(in_array($occur, $this->byday) || in_array($occur_zero, $this->byday) || in_array($occur_neg, $this->byday))
+ {
+ $tmp_array[] = clone $date_time;
+ }
+ }
+
+ if($_pos > 0)
+ {
+ $this->suggestions[] = clone $tmp_array[$_pos - 1];
+ }
+ else
+ {
+ $this->suggestions[] = clone $tmp_array[count($tmp_array) + $_pos];
+ }
+
+ }
+ }
+ }
+ }
+ elseif($this->gobyyearday)
+ {
+ foreach($this->byyearday as $_day)
+ {
+ if($_day >= 0)
+ {
+ $_day--;
+
+ $_time = strtotime('+' . $_day . ' days', mktime(0, 0, 0, 1, 1, $year));
+ $this->suggestions[] = new Datetime(date('Y-m-d', $_time) . ' ' . $timestamp);
+ }
+ else
+ {
+ $year_day_neg = 365 + $_day;
+ $leap_year = $this->try_date->format('L');
+ if($leap_year == 1)
+ {
+ $year_day_neg = 366 + $_day;
+ }
+
+ $_time = strtotime('+' . $year_day_neg . ' days', mktime(0, 0, 0, 1, 1, $year));
+ $this->suggestions[] = new Datetime(date('Y-m-d', $_time) . ' ' . $timestamp);
+ }
+ }
+ }
+ // special case because for years you need to loop through the months too
+ elseif($this->gobyday && $interval == "year")
+ {
+ foreach($this->bymonth as $_month)
+ {
+ // this creates an array of days of the month
+ $_mdays = range(1, date('t',mktime(0,0,0,$_month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $_month . '-' . $_mday . ' ' . $timestamp);
+
+ // get the week of the month (1, 2, 3, 4, 5, etc)
+ $week = $date_time->format('W');
+
+ if($date_time >= $this->start_date && in_array($week, $this->byweekno))
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ }
+ elseif($interval == "day")
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+ elseif($interval == "week")
+ {
+ $this->suggestions[] = clone $this->try_date;
+
+ if($this->gobyday)
+ {
+ $week_day = $this->try_date->format('w');
+
+ $days_in_month = $this->try_date->format('t');
+
+ $overflow_count = 1;
+ $_day = $month_day;
+
+ $run = true;
+ while($run)
+ {
+ $_day++;
+ if($_day <= $days_in_month)
+ {
+ $tmp_date = new DateTime($year . '-' . $month . '-' . $_day . ' ' . $timestamp);
+ }
+ else
+ {
+ //$tmp_month = $month+1;
+ $tmp_date = new DateTime($year . '-' . $month . '-' . $overflow_count . ' ' . $timestamp);
+ $tmp_date->modify('+1 month');
+ $overflow_count++;
+ }
+
+ $week_day = $tmp_date->format('w');
+
+ if($this->try_date == $this->start_date)
+ {
+ if($week_day == $this->wkst)
+ {
+ $this->try_date = clone $tmp_date;
+ $this->try_date->modify('-7 days');
+ $run = false;
+ }
+ }
+
+ if($week_day != $this->wkst)
+ {
+ $this->suggestions[] = clone $tmp_date;
+ }
+ else
+ {
+ $run = false;
+ }
+ }
+ }
+ }
+ elseif($this->gobyday || $interval == "month")
+ {
+ $_mdays = range(1, date('t',mktime(0,0,0,$month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $month . '-' . $_mday . ' ' . $timestamp);
+
+ // get the week of the month (1, 2, 3, 4, 5, etc)
+ $week = $date_time->format('W');
+
+ if($date_time >= $this->start_date && in_array($week, $this->byweekno))
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ elseif($this->gobymonth)
+ {
+ foreach($this->bymonth as $_month)
+ {
+ $date_time = new DateTime($year . '-' . $_month . '-' . $month_day . ' ' . $timestamp);
+
+ if($date_time >= $this->start_date)
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ else
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+
+ if($interval == "month")
+ {
+ $this->try_date->modify('last day of ' . $this->interval . ' ' . $interval);
+ }
+ else
+ {
+ $this->try_date->modify($this->interval . ' ' . $interval);
+ }
+ }
+
+ protected function valid_date($date)
+ {
+ $year = $date->format('Y');
+ $month = $date->format('n');
+ $day = $date->format('j');
+
+ $year_day = $date->format('z') + 1;
+
+ $year_day_neg = -366 + $year_day;
+ $leap_year = $date->format('L');
+ if($leap_year == 1)
+ {
+ $year_day_neg = -367 + $year_day;
+ }
+
+ // this is the nth occurence of the date
+ $occur = ceil($day / 7);
+
+ $week = $date->format('W');
+
+ $day_of_week = $date->format('l');
+ $dow_abr = strtoupper(substr($day_of_week, 0, 2));
+
+ // set the day of the month + (positive)
+ $occur = '+' . $occur . $dow_abr;
+ $occur_zero = '+0' . $dow_abr;
+
+ // set the day of the month - (negative)
+ $total_days = $date->format('t') - $date->format('j');
+ $occur_neg = '-' . ceil(($total_days + 1)/7) . $dow_abr;
+
+ $day_from_end_of_month = $date->format('t') + 1 - $day;
+
+ if(in_array($month, $this->bymonth) &&
+ (in_array($occur, $this->byday) || in_array($occur_zero, $this->byday) || in_array($occur_neg, $this->byday)) &&
+ in_array($week, $this->byweekno) &&
+ (in_array($day, $this->bymonthday) || in_array(-$day_from_end_of_month, $this->bymonthday)) &&
+ (in_array($year_day, $this->byyearday) || in_array($year_day_neg, $this->byyearday)))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ // return the next valid DateTime object which matches the pattern and follows the rules
+ public function next()
+ {
+ // check the counter is set
+ if($this->count !== 0)
+ {
+ if($this->counter >= $this->count)
+ {
+ return false;
+ }
+ }
+
+ // create initial set of suggested dates
+ if(count($this->suggestions) === 0)
+ {
+ $this->create_suggestions();
+ }
+
+ // loop through the suggested dates
+ while(count($this->suggestions) > 0)
+ {
+ // get the first one on the array
+ $try_date = array_shift($this->suggestions);
+
+ // make sure the date doesn't exceed the max date
+ if($try_date > $this->end_date)
+ {
+ return false;
+ }
+
+ // make sure it falls within the allowed days
+ if($this->valid_date($try_date) === true)
+ {
+ $this->counter++;
+ return $try_date;
+ }
+ else
+ {
+ // we might be out of suggested days, so load some more
+ if(count($this->suggestions) === 0)
+ {
+ $this->create_suggestions();
+ }
+ }
+ }
+ }
+}
diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php
new file mode 100644
index 0000000000..e2169b5dd7
--- /dev/null
+++ b/apps/admin_dependencies_chk/appinfo/app.php
@@ -0,0 +1,9 @@
+ 14,
+ 'id' => 'admin_dependencies_chk',
+ 'name' => 'Owncloud Install Info' ));
+
+OC_APP::registerAdmin('admin_dependencies_chk','settings');
diff --git a/apps/admin_dependencies_chk/appinfo/info.xml b/apps/admin_dependencies_chk/appinfo/info.xml
new file mode 100644
index 0000000000..10721ece15
--- /dev/null
+++ b/apps/admin_dependencies_chk/appinfo/info.xml
@@ -0,0 +1,11 @@
+
+
+ admin_dependencies_chk
+ Owncloud dependencies info
+ 0.01
+ AGPL
+ Brice Maron (eMerzh)
+ 2
+ Display OwnCloud's dependencies informations (missings modules, ...)
+
+
diff --git a/apps/admin_dependencies_chk/css/style.css b/apps/admin_dependencies_chk/css/style.css
new file mode 100644
index 0000000000..30f204be7b
--- /dev/null
+++ b/apps/admin_dependencies_chk/css/style.css
@@ -0,0 +1,9 @@
+#status_list legend { font-weight: bold; color: #888888; }
+.state > li { margin-bottom: 3px; padding-left: 0.5em; list-style-type: circle; }
+.state .state_module { font-weight:bold; text-shadow: 0 1px 0 #DDD; cursor:help;}
+
+.state_used ul, .state_used li { display:inline; }
+
+.state_ok .state_module { color: #009700; }
+.state_warning .state_module { color: #FF9B29; }
+.state_error .state_module { color: #FF3B3B; }
diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php
new file mode 100644
index 0000000000..34028056db
--- /dev/null
+++ b/apps/admin_dependencies_chk/settings.php
@@ -0,0 +1,96 @@
+.
+ *
+ */
+$l=new OC_L10N('admin_dependencies_chk');
+$tmpl = new OC_Template( 'admin_dependencies_chk', 'settings');
+
+$modules = array();
+
+//Possible status are : ok, error, warning
+$modules[] =array(
+ 'status' => function_exists('json_encode') ? 'ok' : 'error',
+ 'part'=> 'php-json',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-json module is needed by the many applications for inter communications'));
+
+$modules[] =array(
+ 'status' => function_exists('curl_init') ? 'ok' : 'error',
+ 'part'=> 'php-curl',
+ 'modules'=> array('bookmarks'),
+ 'message'=> $l->t('The php-curl modude is needed to fetch the page title when adding a bookmarks'));
+
+$modules[] =array(
+ 'status' => function_exists('imagepng') ? 'ok' : 'error',
+ 'part'=> 'php-gd',
+ 'modules'=> array('gallery'),
+ 'message'=> $l->t('The php-gd module is needed to create thumbnails of your images'));
+
+$modules[] =array(
+ 'status' => OC_Helper::canExecute("mp3info") ? 'ok' : 'warning',
+ 'part'=> 'mp3info',
+ 'modules'=> array('media'),
+ 'message'=> $l->t('The program mp3info is useful to discover ID3 tags of your music files'));
+
+$modules[] =array(
+ 'status' => function_exists("ldap_bind") ? 'ok' : 'error',
+ 'part'=> 'php-ldap',
+ 'modules'=> array('user_ldap'),
+ 'message'=> $l->t('The php-ldap module is needed connect to your ldap server'));
+
+$modules[] =array(
+ 'status' => class_exists('ZipArchive') ? 'ok' : 'warning',
+ 'part'=> 'php-zip',
+ 'modules'=> array('admin_export','core'),
+ 'message'=> $l->t('The php-zip module is needed download multiple files at once'));
+
+$modules[] =array(
+ 'status' => function_exists('mb_detect_encoding') ? 'ok' : 'error',
+ 'part'=> 'php-mb_multibyte ',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-mb_multibyte module is needed to manage correctly the encoding.'));
+
+$modules[] =array(
+ 'status' => function_exists('ctype_digit') ? 'ok' : 'error',
+ 'part'=> 'php-ctype',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-ctype module is needed validate data.'));
+
+$modules[] =array(
+ 'status' => ini_get('allow_url_fopen') == '1' ? 'ok' : 'error',
+ 'part'=> 'allow_url_fopen',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The allow_url_fopen directive of your php.ini should be set to 1 to retrieve knowledge base from OCS servers'));
+
+foreach($modules as $key => $module) {
+ $enabled = false ;
+ foreach($module['modules'] as $app) {
+ if(OC_App::isEnabled($app) || $app=='core'){
+ $enabled = true;
+ }
+ }
+ if($enabled == false) unset($modules[$key]);
+}
+
+OC_UTIL::addStyle('admin_dependencies_chk', 'style');
+$tmpl->assign( 'items', $modules );
+
+return $tmpl->fetchPage();
diff --git a/apps/admin_dependencies_chk/templates/settings.php b/apps/admin_dependencies_chk/templates/settings.php
new file mode 100644
index 0000000000..8ff27ebb18
--- /dev/null
+++ b/apps/admin_dependencies_chk/templates/settings.php
@@ -0,0 +1,16 @@
+
+ t('Dependencies status');?>
+
+
+
+
+ t('Used by :');?>
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php
index 3975fd15f8..45b16ae5fa 100644
--- a/apps/bookmarks/ajax/addBookmark.php
+++ b/apps/bookmarks/ajax/addBookmark.php
@@ -54,13 +54,7 @@ $params=array(
);
$query->execute($params);
-if($CONFIG_DBTYPE == 'pgsql')
-{
- $query = OC_DB::prepare("SELECT currval('*PREFIX*bookmarks_id_seq')");
- $b_id = $query->execute()->fetchOne();
-} else {
- $b_id = OC_DB::insertid();
-}
+$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php
index 44d4235b9b..ac512fbc24 100644
--- a/apps/bookmarks/bookmarksHelper.php
+++ b/apps/bookmarks/bookmarksHelper.php
@@ -56,6 +56,9 @@ function getURLMetadata($url) {
}
$metadata['url'] = $url;
+ if (!function_exists('curl_init')){
+ return $metadata;
+ }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -66,4 +69,4 @@ function getURLMetadata($url) {
$metadata['title'] = htmlspecialchars_decode(@$match[1]);
return $metadata;
-}
\ No newline at end of file
+}
diff --git a/apps/bookmarks/settings.php b/apps/bookmarks/settings.php
index 8186472dec..0ace04fa2c 100644
--- a/apps/bookmarks/settings.php
+++ b/apps/bookmarks/settings.php
@@ -8,6 +8,6 @@
$tmpl = new OC_Template( 'bookmarks', 'settings');
-OC_Util::addScript('bookmarks','settings');
+//OC_Util::addScript('bookmarks','settings');
return $tmpl->fetchPage();
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 89239f2175..3c2bc6de23 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -12,6 +12,10 @@ if(!OC_USER::isLoggedIn()) {
}
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$cal = OC_Calendar_Calendar::findCalendar($calendarid);
-echo $cal['active'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);
+OC_JSON::success(array(
+ 'active' => $calendar['active'],
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php
index b396ff4945..ef05c7cd49 100644
--- a/apps/calendar/ajax/changeview.php
+++ b/apps/calendar/ajax/changeview.php
@@ -7,10 +7,9 @@
*/
require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$currentview = $_GET["v"];
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
+OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php
index 3fb2e8398a..f8b5974f54 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/createcalendar.php
@@ -8,8 +8,6 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
@@ -17,7 +15,11 @@ OC_JSON::checkAppEnabled('calendar');
$userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php
index e8ffe0d059..fc308da6da 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/deletecalendar.php
@@ -7,19 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('');
}
OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error(array('error'=>'permission_denied'));
- exit;
-}
+$calendar = OC_Calendar_App::getCalendar($cal);
$del = OC_Calendar_Calendar::deleteCalendar($cal);
if($del == true){
OC_JSON::success();
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php
index 9e3c7dd87d..269f4a47f4 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/deleteevent.php
@@ -15,17 +15,7 @@ if(!OC_USER::isLoggedIn()) {
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
-$data = OC_Calendar_Object::find($id);
-if (!$data)
-{
- OC_JSON::error();
- exit;
-}
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
-}
+$event_object = OC_Calendar_App::getEventObject($id);
$result = OC_Calendar_Object::delete($id);
OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
index d23e528786..e44763c9aa 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/editcalendar.php
@@ -7,13 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("");
}
OC_JSON::checkAppEnabled('calendar');
+
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
-$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
+$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index 3abf4de98b..f00ab1d960 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -7,9 +7,6 @@
*/
require_once('../../../lib/base.php');
-
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('');
}
@@ -23,19 +20,12 @@ if($errarr){
}else{
$id = $_POST['id'];
$cal = $_POST['calendar'];
- $data = OC_Calendar_Object::find($id);
- if (!$data)
- {
- OC_JSON::error();
- exit;
- }
- $calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
- if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
- $vcalendar = Sabre_VObject_Reader::read($data['calendardata']);
+ $data = OC_Calendar_App::getEventObject($id);
+ $vcalendar = OC_VObject::parse($data['calendardata']);
+
+ OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']);
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
+
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
if ($data['calendarid'] != $cal) {
OC_Calendar_Object::moveToCalendar($id, $cal);
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 34d6c657ce..fe6c6f7357 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -8,26 +8,16 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('');
}
OC_JSON::checkAppEnabled('calendar');
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
-
$id = $_GET['id'];
-$data = OC_Calendar_Object::find($id);
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- echo $l10n->t('Wrong calendar');
- exit;
-}
-$object = Sabre_VObject_Reader::read($data['calendardata']);
+$data = OC_Calendar_App::getEventObject($id);
+$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
+
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch($dtstart->getDateType()) {
@@ -49,23 +39,30 @@ switch($dtstart->getDateType()) {
break;
}
-$summary = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
-$location = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
-$categories = array();
-if (isset($vevent->CATEGORIES)){
- $categories = explode(',', $vevent->CATEGORIES->value);
- $categories = array_map('trim', $categories);
-}
+$summary = $vevent->getAsString('SUMMARY');
+$location = $vevent->getAsString('LOCATION');
+$categories = $vevent->getAsArray('CATEGORIES');
+$repeat = $vevent->getAsString('CATEGORY');
+$description = $vevent->getAsString('DESCRIPTION');
foreach($categories as $category){
if (!in_array($category, $category_options)){
array_unshift($category_options, $category);
}
}
-$repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
-$description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
+$last_modified = $vevent->__get('LAST-MODIFIED');
+if ($last_modified){
+ $lastmodified = $last_modified->getDateTime()->format('U');
+}else{
+ $lastmodified = 0;
+}
+
+$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
$tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
+$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
new file mode 100644
index 0000000000..1430432b8a
--- /dev/null
+++ b/apps/calendar/ajax/events.php
@@ -0,0 +1,84 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once ('../../../lib/base.php');
+require_once('../../../3rdparty/when/When.php');
+
+function addoutput($event, $vevent, $return_event){
+ $return_event['id'] = (int)$event['id'];
+ $return_event['title'] = $event['summary'];
+ $return_event['description'] = isset($vevent->DESCRIPTION)?$vevent->DESCRIPTION->value:'';
+ $last_modified = $vevent->__get('LAST-MODIFIED');
+ if ($last_modified){
+ $lastmodified = $last_modified->getDateTime()->format('U');
+ }else{
+ $lastmodified = 0;
+ }
+ $return_event['lastmodified'] = (int)$lastmodified;
+ return $return_event;
+}
+
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+
+$start = DateTime::createFromFormat('U', $_GET['start']);
+$end = DateTime::createFromFormat('U', $_GET['end']);
+
+$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
+$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$return = array();
+foreach($events as $event){
+ $object = OC_VObject::parse($event['calendardata']);
+ $vevent = $object->VEVENT;
+ $dtstart = $vevent->DTSTART;
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+ $return_event = array();
+ $start_dt = $dtstart->getDateTime();
+ $start_dt->setTimezone(new DateTimeZone($user_timezone));
+ $end_dt = $dtend->getDateTime();
+ $end_dt->setTimezone(new DateTimeZone($user_timezone));
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
+ $return_event['allDay'] = true;
+ }else{
+ $return_event['allDay'] = false;
+ }
+ //Repeating Events
+ if($event['repeating'] == 1){
+ $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
+ $r = new When();
+ $r->recur((string) $start_dt->format('Ymd\THis'))->rrule((string) $vevent->RRULE);
+ while($result = $r->next()){
+ if($result->format('U') > $_GET['end']){
+ break;
+ }
+ if($return_event['allDay'] == true){
+ $return_event['start'] = $result->format('Y-m-d');
+ $return_event['end'] = date('Y-m-d', $result->format('U') + $duration--);
+ }else{
+ $return_event['start'] = $result->format('Y-m-d H:i:s');
+ $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
+ }
+ $return[] = addoutput($event, $vevent, $return_event);
+ }
+ }else{
+ $return_event = array();
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
+ $return_event['allDay'] = true;
+ $return_event['start'] = $start_dt->format('Y-m-d');
+ $end_dt->modify('-1 sec');
+ $return_event['end'] = $end_dt->format('Y-m-d');
+ }else{
+ $return_event['start'] = $start_dt->format('Y-m-d H:i:s');
+ $return_event['end'] = $end_dt->format('Y-m-d H:i:s');
+ $return_event['allDay'] = false;
+ }
+ $return[] = addoutput($event, $vevent, $return_event);
+ }
+}
+OC_JSON::encodedPrint($return);
+?>
\ No newline at end of file
diff --git a/apps/calendar/ajax/getcal.php b/apps/calendar/ajax/getcal.php
deleted file mode 100644
index a65c6cf260..0000000000
--- a/apps/calendar/ajax/getcal.php
+++ /dev/null
@@ -1,70 +0,0 @@
-
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("");
-}
-OC_JSON::checkAppEnabled('calendar');
-
-$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
-$events = array();
-$return = array('calendars'=>array());
-foreach($calendars as $calendar) {
- $tmp = OC_Calendar_Object::all($calendar['id']);
- $events = array_merge($events, $tmp);
- $return['calendars'][$calendar['id']] = array(
- 'displayname' => $calendar['displayname'],
- 'color' => '#'.$calendar['calendarcolor']
- );
-}
-
-$select_year = $_GET["year"];
-$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
-foreach($events as $event)
-{
- if ($select_year != substr($event['startdate'], 0, 4))
- continue;
- $object = Sabre_VObject_Reader::read($event['calendardata']);
- $vevent = $object->VEVENT;
- $dtstart = $vevent->DTSTART;
- $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
- $start_dt = $dtstart->getDateTime();
- $start_dt->setTimezone(new DateTimeZone($user_timezone));
- $end_dt = $dtend->getDateTime();
- $end_dt->setTimezone(new DateTimeZone($user_timezone));
- $year = $start_dt->format('Y');
- $month = $start_dt->format('n') - 1; // return is 0 based
- $day = $start_dt->format('j');
- $hour = $start_dt->format('G');
- if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE) {
- $hour = 'allday';
- }
-
- $return_event = array();
- foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop)
- {
- $return_event[$prop] = $event[$prop];
- }
- $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i'));
- $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i'));
- $return_event['description'] = $event['summary'];
- if ($hour == 'allday')
- {
- $return_event['allday'] = true;
- }
- if (isset($return[$year][$month][$day][$hour]))
- {
- $return[$year][$month][$day][$hour][] = $return_event;
- }
- else
- {
- $return[$year][$month][$day][$hour] = array(1 => $return_event);
- }
-}
-OC_JSON::encodedPrint($return);
diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/guesstimezone.php
new file mode 100755
index 0000000000..a3594498b0
--- /dev/null
+++ b/apps/calendar/ajax/guesstimezone.php
@@ -0,0 +1,39 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+function make_array_out_of_xml ($xml){
+ $returnarray = array();
+ $xml = (array)$xml ;
+ foreach ($xml as $property => $value){
+ $value = (array)$value;
+ if(!isset($value[0])){
+ $returnarray[$property] = make_array_out_of_xml($value);
+ }else{
+ $returnarray[$property] = trim($value[0]);
+ }
+ }
+ return $returnarray;
+}
+require_once ("../../../lib/base.php");
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+$l = new OC_L10N('calendar');
+$lat = $_GET['lat'];
+$long = $_GET['long'];
+$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long);
+//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
+$geoxml = simplexml_load_string($geolocation);
+$geoarray = make_array_out_of_xml($geoxml);
+if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezoneId'] != ''){
+ OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
+ $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']);
+ OC_JSON::success($message);
+}else{
+ OC_JSON::error();
+}
+
+?>
\ No newline at end of file
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
index e2b777969d..f2256d4eee 100644
--- a/apps/calendar/ajax/moveevent.php
+++ b/apps/calendar/ajax/moveevent.php
@@ -1,103 +1,43 @@
+ * Copyright (c) 2011 Bart Visscher
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
-error_reporting(E_ALL);
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$data = OC_Calendar_Object::find($_POST["id"]);
-$calendarid = $data["calendarid"];
-$cal = $calendarid;
-$id = $_POST["id"];
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
-if(OC_User::getUser() != $calendar["userid"]){
- OC_JSON::error();
- exit;
-}
-$newdate = $_POST["newdate"];
-$caldata = array();
-//modified part of editeventform.php
-$object = Sabre_VObject_Reader::read($data['calendardata']);
-$vevent = $object->VEVENT;
+
+$id = $_POST['id'];
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
+$allday = $_POST['allDay'];
+$delta = new DateInterval('P0D');
+$delta->d = $_POST['dayDelta'];
+$delta->i = $_POST['minuteDelta'];
+
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
+
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
-switch($dtstart->getDateType()) {
- case Sabre_VObject_Element_DateTime::LOCALTZ:
- case Sabre_VObject_Element_DateTime::LOCAL:
- $startdate = $dtstart->getDateTime()->format('d-m-Y');
- $starttime = $dtstart->getDateTime()->format('H:i');
- $enddate = $dtend->getDateTime()->format('d-m-Y');
- $endtime = $dtend->getDateTime()->format('H:i');
- $allday = false;
- break;
- case Sabre_VObject_Element_DateTime::DATE:
- $startdate = $dtstart->getDateTime()->format('d-m-Y');
- $starttime = '00:00';
- $dtend->getDateTime()->modify('-1 day');
- $enddate = $dtend->getDateTime()->format('d-m-Y');
- $endtime = '23:59';
- $allday = true;
- break;
+$start_type = $dtstart->getDateType();
+$end_type = $dtend->getDateType();
+if ($allday && $start_type != Sabre_VObject_Element_DateTime::DATE){
+ $start_type = $end_type = Sabre_VObject_Element_DateTime::DATE;
+ $dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type);
}
-$caldata["title"] = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
-$caldata["location"] = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
-$caldata["categories"] = array();
-if (isset($vevent->CATEGORIES)){
- $caldata["categories"] = explode(',', $vevent->CATEGORIES->value);
- $caldata["categories"] = array_map('trim', $categories);
+if (!$allday && $start_type == Sabre_VObject_Element_DateTime::DATE){
+ $start_type = $end_type = Sabre_VObject_Element_DateTime::LOCALTZ;
}
-foreach($caldata["categories"] as $category){
- if (!in_array($category, $category_options)){
- array_unshift($category_options, $category);
- }
-}
-$caldata["repeat"] = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
-$caldata["description"] = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
-//end part of editeventform.php
-$startdatearray = explode("-", $startdate);
-$starttimearray = explode(":", $starttime);
-$startunix = mktime($starttimearray[0], $starttimearray[1], 0, $startdatearray[1], $startdatearray[0], $startdatearray[2]);
-$enddatearray = explode("-", $enddate);
-$endtimearray = explode(":", $endtime);
-$endunix = mktime($endtimearray[0], $endtimearray[1], 0, $enddatearray[1], $enddatearray[0], $enddatearray[2]);
-$difference = $endunix - $startunix;
-if(strlen($newdate) > 10){
- $newdatestringarray = explode("-", $newdate);
- if($newdatestringarray[1] == "allday"){
- $allday = true;
- $newdatestringarray[1] = "00:00";
- }else{
- if($allday == true){
- $difference = 3600;
- }
- $allday = false;
- }
-}else{
- $newdatestringarray = array();
- $newdatestringarray[0] = $newdate;
- $newdatestringarray[1] = $starttime;
-}
-$newdatearray = explode(".", $newdatestringarray[0]);
-$newtimearray = explode(":", $newdatestringarray[1]);
-$newstartunix = mktime($newtimearray[0], $newtimearray[1], 0, $newdatearray[1], $newdatearray[0], $newdatearray[2]);
-$newendunix = $newstartunix + $difference;
-if($allday == true){
- $caldata["allday"] = true;
-}else{
- unset($caldata["allday"]);
-}
-$caldata["from"] = date("d-m-Y", $newstartunix);
-$caldata["fromtime"] = date("H:i", $newstartunix);
-$caldata["to"] = date("d-m-Y", $newendunix);
-$caldata["totime"] = date("H:i", $newendunix);
-//modified part of editevent.php
-$vcalendar = Sabre_VObject_Reader::read($data["calendardata"]);
-OC_Calendar_Object::updateVCalendarFromRequest($caldata, $vcalendar);
+$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type);
+$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
+unset($vevent->DURATION);
+
+$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
-OC_JSON::success();
-//end part of editevent.php
-?>
\ No newline at end of file
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 9d4dcfa2e1..e12e99219e 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -8,50 +8,40 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('');
}
OC_JSON::checkAppEnabled('calendar');
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
-$startday = substr($_GET['d'], 0, 2);
-$startmonth = substr($_GET['d'], 2, 2);
-$startyear = substr($_GET['d'], 4, 4);
-$starttime = $_GET['t'];
-$allday = $starttime == 'allday';
-if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
- $startminutes = '00';
-}elseif($allday){
- $starttime = '0';
- $startminutes = '00';
-}else{
- $starttime = date('G');
-
- $startminutes = date('i');
+if (!isset($_POST['start'])){
+ OC_JSON::error();
+ die;
}
+$start = $_POST['start'];
+$end = $_POST['end'];
+$allday = $_POST['allday'];
-$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
-$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
-$datetimestamp = $datetimestamp + ($duration * 60);
-$endmonth = date("m", $datetimestamp);
-$endday = date("d", $datetimestamp);
-$endyear = date("Y", $datetimestamp);
-$endtime = date("G", $datetimestamp);
-$endminutes = date("i", $datetimestamp);
-
+if (!$end){
+ $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60');
+ $end = $start + ($duration * 60);
+}
+$start = new DateTime('@'.$start);
+$end = new DateTime('@'.$end);
+$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$start->setTimezone(new DateTimeZone($timezone));
+$end->setTimezone(new DateTimeZone($timezone));
+$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
-$tmpl->assign('startdate', $startday . '-' . $startmonth . '-' . $startyear);
-$tmpl->assign('starttime', ($starttime <= 9 ? '0' : '') . $starttime . ':' . $startminutes);
-$tmpl->assign('enddate', $endday . '-' . $endmonth . '-' . $endyear);
-$tmpl->assign('endtime', ($endtime <= 9 ? '0' : '') . $endtime . ':' . $endminutes);
+$tmpl->assign('startdate', $start->format('d-m-Y'));
+$tmpl->assign('starttime', $start->format('H:i'));
+$tmpl->assign('enddate', $end->format('d-m-Y'));
+$tmpl->assign('endtime', $end->format('H:i'));
$tmpl->assign('allday', $allday);
$tmpl->printpage();
?>
diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php
new file mode 100644
index 0000000000..6834790652
--- /dev/null
+++ b/apps/calendar/ajax/resizeevent.php
@@ -0,0 +1,32 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+
+$id = $_POST['id'];
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
+$delta = new DateInterval('P0D');
+$delta->d = $_POST['dayDelta'];
+$delta->i = $_POST['minuteDelta'];
+
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
+
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+$end_type = $dtend->getDateType();
+$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
+unset($vevent->DURATION);
+
+$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
+
+$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php
index a81644ded1..14f560da5a 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -8,16 +8,19 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['id'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_App::getCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 2dc01eab0f..ee990723c0 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -1,5 +1,6 @@
$l->t('Calendar')));
OC_App::registerPersonal('calendar', 'settings');
+
+require_once('apps/calendar/lib/search.php');
diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css
index 80d29ca897..0204f2fc12 100644
--- a/apps/calendar/css/style.css
+++ b/apps/calendar/css/style.css
@@ -17,19 +17,12 @@
#editentry_dialog {display: none;}
#parsingfail_dialog{display: none;}
-#calendar_holder {height: 100%; width: 100%;}
-#onedayview, #oneweekview, #fourweeksview, #onemonthview, #listview {display: none; position: absolute;bottom: 0; right: 0; left: 160px; top: 80px;}
-#onedayview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
-#oneweekview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
-#fourweeksview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;overflow: hidden;}
-#onemonthview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
+#calendar_holder {position: relative;bottom: 0; right: 0; left: 0; top: 3em;}
+.fc-content{padding:2px 4px;}
#listview {margin: 0; padding: 10px; background: #EEEEEE;}
#listview #more_before, #listview #more_after {border: 1px solid #1a1a1a; width:25em;padding: 3px;text-align: center;}
#listview #events {width:25em;padding: 4px;}
#listview #events .day {width:auto;padding-left:10px;border-bottom: 2px solid #EEEEEE;text-align:left;}
-#fourweeksview .calw{vertical-align: middle;text-align: center;width: 50px;}
-
-#sysbox{display: none;}
.actions {height: 33px; min-width: 800px;}
.controls {min-width: 800px;}
@@ -60,3 +53,75 @@ button.category{margin:0 3px;}
.calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;border:2px solid transparent;}
.calendar-colorpicker-color.active{border:2px solid black;}
+
+.fc-list-table
+{
+ margin: 10px;
+ border-style: hidden;
+ border-width: 10px;
+ padding: 10px;
+ vertical-align: top;
+ width: 100%;
+}
+.fc-list-table tr:hover
+{
+ color: #0000FF;
+ background-color: #CCFFCC;
+}
+
+
+.fc-list-date
+{
+ margin: 16px;
+ white-space: nowrap;
+ text-align: left;
+ width: 100%;
+ background-color: #808080;
+ color: #FFFFFF;
+ font-weight: bold;
+ font-family: Arial, Helvetica, sans-serif;
+}
+.fc-list-time
+{
+ text-align: center;
+ white-space: nowrap;
+ width: 1%;
+}
+
+.fc-list-event
+{
+ text-align: left;
+}
+
+.fc-list-event .fc-event-title
+{
+ cursor: pointer;
+}
+.tipsy-event .tipsy-inner{
+background-color:#0098E4;
+border:2px solid #1d2d44;
+max-width:400px;
+padding:0;
+}
+.tipsy-event .tipsy-arrow-s{
+border-top-color:#1d2d44;
+}
+.tipsy-event .tipsy-arrow-n{
+border-bottom-color:#1d2d44;
+}
+.tipsy-event .summary,
+.tipsy-event .timespan,
+.tipsy-event .description{
+padding:0 8px;
+}
+.tipsy-event .summary{
+background-color:#1d2d44;
+font-size:1.2em;
+font-weight:bold;
+text-align:left;
+padding:0 8px 2px;
+}
+.tipsy-event .description{
+line-height:1.2;
+margin-bottom:4px;
+}
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index 3e93a1ad61..9b3ea5005d 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -12,25 +12,17 @@ OC_Util::checkAppEnabled('calendar');
$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL;
$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL;
if(isset($cal)){
- $calendar = OC_Calendar_Calendar::findCalendar($cal);
- if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($cal);
$calobjects = OC_Calendar_Object::all($cal);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
- for($i = 0;$i <= count($calobjects); $i++){
- echo $calobjects[$i]["calendardata"] . "\n";
+ foreach($calobjects as $calobject){
+ echo $calobject["calendardata"] . "\n";
}
}elseif(isset($event)){
- $data = OC_Calendar_Object::find($_GET["eventid"]);
+ $data = OC_Calendar_App::getEventObject($_GET["eventid"]);
$calendarid = $data["calendarid"];
- $calendar = OC_Calendar_Calendar::findCalendar($calendarid);
- if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($calendarid);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
echo $data["calendardata"];
diff --git a/apps/calendar/import.php b/apps/calendar/import.php
index 211791f551..759726b8d1 100644
--- a/apps/calendar/import.php
+++ b/apps/calendar/import.php
@@ -12,11 +12,7 @@ OC_Util::checkAppEnabled('calendar');
if($_GET["import"] == "existing"){
$calid = $_GET["calid"];
- $calendar = OC_Calendar_Calendar::findCalendar($calid);
- if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($calid);
if($_GET["path"] != ""){
$filename = $_GET["path"] . "/" . $_GET["file"];
}else{
@@ -47,4 +43,4 @@ for($i = 1;$i < count($vcalendar);$i++){
OC_Calendar_Object::add($calid, $vcalendar[$i]);
}
OC_JSON::success();
-?>
\ No newline at end of file
+?>
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index 8b8ac72958..3313750d52 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -10,15 +10,36 @@ require_once ('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
// Create default calendar ...
-$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
if( count($calendars) == 0){
OC_Calendar_Calendar::addCalendar(OC_User::getUser(),'Default calendar');
- $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+ $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
}
-OC_UTIL::addScript('calendar', 'calendar');
-OC_UTIL::addStyle('calendar', 'style');
-OC_UTIL::addScript('', 'jquery.multiselect');
-OC_UTIL::addStyle('', 'jquery.multiselect');
-OC_APP::setActiveNavigationEntry('calendar_index');
-$output = new OC_TEMPLATE('calendar', 'calendar', 'user');
-$output -> printPage();
+$eventSources = array();
+foreach($calendars as $calendar){
+ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
+}
+//Fix currentview for fullcalendar
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek");
+}
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "month");
+}
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "list");
+}
+
+OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar');
+OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
+if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null){
+ OC_UTIL::addScript('calendar', 'geo');
+}
+OC_Util::addScript('calendar', 'calendar');
+OC_Util::addStyle('calendar', 'style');
+OC_Util::addScript('', 'jquery.multiselect');
+OC_Util::addStyle('', 'jquery.multiselect');
+OC_App::setActiveNavigationEntry('calendar_index');
+$tmpl = new OC_Template('calendar', 'calendar', 'user');
+$tmpl->assign('eventSources', $eventSources);
+$tmpl->printPage();
\ No newline at end of file
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 2917d9f913..c3644b5370 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -7,262 +7,10 @@
*/
Calendar={
- space:' ',
- firstdayofweek: '',
- weekend: '',
- Date:{
- normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- calw:function() {
- var dayofweek = this.current.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- var calw = Math.floor((this.doy() - dayofweek) / 7) + 1;
- return calw;
- },
-
- doy:function() {
- var cal = this.getnumberofdays(this.current.getFullYear());
- var doy = 0;
- for(var i = 0; i < this.current.getMonth(); i++) {
- doy = doy + cal[i];
- }
- doy = doy + this.current.getDate();
- return doy;
- },
-
- getnumberofdays:function(year) {
- if(this.checkforleapyear(year) == true) {
- var cal = this.leap_year_cal;
- } else {
- var cal = this.normal_year_cal;
- }
- return cal;
- },
-
- checkforleapyear:function(year2check) {
- if((year2check / 600) == Math.floor(year2check / 400)) {
- return true;
- }
- if((year2check / 4) == Math.floor(year2check / 4)) {
- if((year2check / 100) == Math.floor(year2check / 100)) {
- return false;
- }
- return true;
- }
- return false;
- },
-
- current:new Date(),
- forward_day:function(){
- this.current.setDate(this.current.getDate()+1);
- },
-
- forward_week:function(){
- this.current.setDate(this.current.getDate()+7);
- },
-
- forward_month:function(){
- this.current.setMonth(this.current.getMonth()+1);
- },
-
- backward_day:function(){
- this.current.setDate(this.current.getDate()-1);
- },
-
- backward_week:function(){
- this.current.setDate(this.current.getDate()-7);
- },
-
- backward_month:function(){
- this.current.setMonth(this.current.getMonth()-1);
- },
-
- },
UI:{
- weekdays: '',
- formatDayShort:function(day){
- if (typeof(day) == 'undefined'){
- day = Calendar.Date.current.getDay();
- }
- return this.dayshort[day];
- },
- formatDayLong:function(day){
- if (typeof(day) == 'undefined'){
- day = Calendar.Date.current.getDay();
- }
- return this.daylong[day];
- },
- formatMonthShort:function(month){
- if (typeof(month) == 'undefined'){
- month = Calendar.Date.current.getMonth();
- }
- return this.monthshort[month];
- },
- formatMonthLong:function(month){
- if (typeof(month) == 'undefined'){
- month = Calendar.Date.current.getMonth();
- }
- return this.monthlong[month];
- },
- formatDate:function(date){
- return date[0] + '-' + date[1] + '-' + date[2];
- },
- formatTime:function(date){
- return date[3] + ':' + date[4];
- },
- updateView:function() {
- this.current.removeEvents();
- this.current.renderCal();
- this.current.showEvents();
- },
- currentview:'none',
- setCurrentView:function(view){
- if (view == this.currentview){
- return;
- }
- $('#'+this.currentview).hide();
- $('#'+this.currentview + "_radio").removeClass('active');
- this.currentview = view;
- //sending ajax request on every change view
- $("#sysbox").load(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view);
- //not necessary to check whether the response is true or not
- switch(view) {
- case "onedayview":
- this.current = this.OneDay;
- break;
- case "oneweekview":
- this.current = this.OneWeek;
- break;
- case "fourweeksview":
- this.current = this.FourWeeks;
- break;
- case "onemonthview":
- this.current = this.OneMonth;
- break;
- case "listview":
- this.current = this.List;
- break;
- default:
- alert('Unknown view:'+view);
- break;
- }
- $(document).ready(function() {
- $('#'+Calendar.UI.currentview).show();
- $('#'+Calendar.UI.currentview + "_radio")
- .addClass('active');
- Calendar.UI.updateView()
- });
- },
- drageventid: '',
- updateDate:function(direction){
- if(direction == 'forward' && this.current.forward) {
- this.current.forward();
- if(Calendar.Date.current.getMonth() == 11){
- this.loadEvents(Calendar.Date.current.getFullYear() + 1);
- }
- this.updateView();
- }
- if(direction == 'backward' && this.current.backward) {
- this.current.backward();
- if(Calendar.Date.current.getMonth() == 0){
- this.loadEvents(Calendar.Date.current.getFullYear() - 1);
- }
- this.updateView();
- }
- },
- events:[],
- loadEvents:function(year){
- if( typeof (year) == 'undefined') {
- this.events = [];
- year = Calendar.Date.current.getFullYear();
- }
- if( typeof (this.events[year]) == "undefined") {
- this.events[year] = []
- }
- $.getJSON(OC.filePath('calendar', 'ajax', 'getcal.php') + "?year=" + year, function(jsondata, status) {
- if(status == "nosession") {
- alert("You are not logged in. That can happen if you don't use owncloud for a long time.");
- document.location(oc_webroot);
- }
- if(status == "parsingfail" || typeof (jsondata) == "undefined") {
- $.ready(function() {
- $( "#parsingfail_dialog" ).dialog();
- });
- } else {
- if (typeof(jsondata[year]) != 'undefined'){
- Calendar.UI.calendars = jsondata['calendars'];
- Calendar.UI.events[year] = jsondata[year];
- }
- $(document).ready(function() {
- Calendar.UI.updateView();
- });
- }
- });
- window.setTimeout("Calendar.UI.loadEvents(" + year + ")", 120000);
- },
- getEventsForDate:function(date){
- var day = date.getDate();
- var month = date.getMonth();
- var year = date.getFullYear();
- if( typeof (this.events[year]) == "undefined") {
- this.loadEvents(year);
- return false;
- }
- if( typeof (this.events[year][month]) == "undefined") {
- return false;
- }
- if( typeof (this.events[year][month][day]) == "undefined") {
- return false;
- }
- return this.events[year][month][day];
- },
- createEventsForDate:function(date, week){
- events = this.getEventsForDate(date);
- if (!events) {
- return;
- }
- var weekday = (date.getDay()+7-Calendar.firstdayofweek)%7;
- if( typeof (events["allday"]) != "undefined") {
- var eventnumber = 1;
- var eventcontainer = this.current.getEventContainer(week, weekday, "allday");
- while( typeof (events["allday"][eventnumber]) != "undefined") {
- this.addEventLabel(eventcontainer, events['allday'][eventnumber]);
- eventnumber++;
- }
- }
- for(var time = 0; time <= 23; time++) {
- if( typeof (events[time]) != "undefined") {
- var eventnumber = 1;
- var eventcontainer = this.current.getEventContainer(week, weekday, time);
- while( typeof (events[time][eventnumber]) != "undefined") {
- this.addEventLabel(eventcontainer, events[time][eventnumber]);
- eventnumber++;
- }
- }
- }
- },
- addEventLabel:function(eventcontainer, event){
- var event_holder = this.current.createEventLabel(event)
- .addClass('event')
- .data('event_info', event)
- .hover(this.createEventPopup,
- this.hideEventPopup)
- .draggable({
- drag: function() {
- Calendar.UI.drageventid = event.id;
- }
- })
- .click(this.editEvent);
- var color = this.calendars[event['calendarid']]['color'];
- if (color){
- event_holder.css('background-color', color)
- .addClass('colored');
- }
- eventcontainer.append(event_holder);
- },
startEventDialog:function(){
+ $('.tipsy').remove();
+ $('#calendar_holder').fullCalendar('unselect');
Calendar.UI.lockTime();
$( "#from" ).datepicker({
dateFormat : 'dd-mm-yy'
@@ -284,30 +32,20 @@ Calendar={
}
});
},
- newEvent:function(selector, time){
- var date_info = $(selector).data('date_info');
- var dayofmonth = date_info.getDate();
- var month = date_info.getMonth();
- var year = date_info.getFullYear();
- if(dayofmonth <= 9){
- dayofmonth = '0' + dayofmonth;
+ newEvent:function(start, end, allday){
+ start = Math.round(start.getTime()/1000);
+ if (end){
+ end = Math.round(end.getTime()/1000);
}
- month++;
- if(month <= 9){
- month = '0' + month;
- }
- var date = String(dayofmonth) + String(month) + String(year);
if($('#event').dialog('isOpen') == true){
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
- $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php') + '?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
+ $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
}
},
- editEvent:function(event){
- event.stopPropagation();
- var event_data = $(this).data('event_info');
- var id = event_data.id;
+ editEvent:function(calEvent, jsEvent, view){
+ var id = calEvent.id;
if($('#event').dialog('isOpen') == true){
// TODO: save event
$('#event').dialog('destroy').remove();
@@ -316,14 +54,14 @@ Calendar={
}
},
submitDeleteEventForm:function(url){
- var post = $( "#event_form" ).serialize();
- $("#errorbox").empty();
+ var post = $( '#event_form' ).serialize();
+ $('#errorbox').empty();
$.post(url, post, function(data){
if(data.status == 'success'){
+ $('#calendar_holder').fullCalendar('removeEvents', $('#event_form input[name=id]').val());
$('#event').dialog('destroy').remove();
- Calendar.UI.loadEvents();
} else {
- $("#errorbox").html("Deletion failed");
+ $('#errorbox').html(t('calendar', 'Deletion failed'));
}
}, "json");
@@ -334,27 +72,27 @@ Calendar={
$.post(url, post,
function(data){
if(data.status == "error"){
- var output = "Missing fields: ";
+ var output = missing_field + ": ";
if(data.title == "true"){
- output = output + "Title ";
+ output = output + missing_field_title + " ";
}
if(data.cal == "true"){
- output = output + "Calendar ";
+ output = output + missing_field_calendar + " ";
}
if(data.from == "true"){
- output = output + "From Date ";
+ output = output + missing_field_fromdate + " ";
}
if(data.fromtime == "true"){
- output = output + "From Time ";
+ output = output + missing_field_fromtime + " ";
}
if(data.to == "true"){
- output = output + "To Date ";
+ output = output + missing_field_todate + " ";
}
if(data.totime == "true"){
- output = output + "To Time ";
+ output = output + missing_field_totime + " ";
}
if(data.endbeforestart == "true"){
- output = "The event ends before it starts!";
+ output = output + missing_field_startsbeforeends + "! ";
}
if(data.dberror == "true"){
output = "There was a database fail!";
@@ -363,65 +101,54 @@ Calendar={
} else
if(data.status == 'success'){
$('#event').dialog('destroy').remove();
- Calendar.UI.loadEvents();
+ $('#calendar_holder').fullCalendar('refetchEvents');
}
},"json");
},
- moveevent:function(eventid, newstartdate){
- $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate},
+ moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
+ $('.tipsy').remove();
+ $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
function(data) {
- console.log("Event moved successfully");
+ if (data.status == 'success'){
+ event.lastmodified = data.lastmodified;
+ console.log("Event moved successfully");
+ }else{
+ revertFunc();
+ $('#calendar_holder').fullCalendar('refetchEvents');
+ }
+ });
+ },
+ resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
+ $('.tipsy').remove();
+ $.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
+ function(data) {
+ if (data.status == 'success'){
+ event.lastmodified = data.lastmodified;
+ console.log("Event resized successfully");
+ }else{
+ revertFunc();
+ $('#calendar_holder').fullCalendar('refetchEvents');
+ }
});
},
showadvancedoptions:function(){
$("#advanced_options").css("display", "block");
$("#advanced_options_button").css("display", "none");
},
- createEventPopup:function(e){
- var popup = $(this).data('popup');
- if (!popup){
- var event = $(this).data('event_info');
- popup = $(document.createElement('div'));
- $(this).data('popup', popup).append(popup);
- popup.addClass('popup')
- popup.addClass('event_popup')
- .html(Calendar.UI.getEventPopupText(event));
- }
- popup.css('left', -(popup.width() - $(this).width())/2)
- .show();
- },
- hideEventPopup:function(){
- $(this).data('popup').hide();
- },
getEventPopupText:function(event){
- var startdate = this.formatDate(event.startdate)
- var starttime = this.formatTime(event.startdate)
- var enddate = this.formatDate(event.enddate)
- var endtime = this.formatTime(event.enddate)
- if (event.allday){
- var timespan = startdate;
- if (event.startdate[2] != parseInt(event.enddate[2])-1){
- timespan += ' - ' + enddate;
- }
+ if (event.allDay){
+ var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}")
}else{
- var start = startdate + ' ' + starttime;
- if (startdate == enddate){
- var end = endtime;
- }else{
- var end = enddate + ' ' + endtime;
- }
- var timespan = start + ' - ' + end;
+ var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy] ' + defaulttime + '{ -[ ddd d MMMM yyyy]' + defaulttime + '}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy] HH:mm{ -[ ddd d MMMM yyyy] HH:mm}")
+ // Tue 18 October 2011 08:00 - 16:00
}
- return '' + timespan + ' '
- + ' '
- + '' + event.description + ' ';
- },
- addDateInfo:function(selector, date){
- $(selector).data('date_info', date);
- },
- switch2Today:function(){
- Calendar.Date.current = new Date();
- Calendar.UI.updateView();
+ var html =
+ '' + event.title + '
' +
+ '' + timespan + '
';
+ if (event.description){
+ html += '' + event.description + '
';
+ }
+ return html;
},
lockTime:function(){
if($('#allday_checkbox').is(':checked')) {
@@ -441,54 +168,41 @@ Calendar={
$('#caldav_url').show();
$("#caldav_url_close").show();
},
- deleteCalendar:function(calid){
- var check = confirm("Do you really want to delete this calendar?");
- if(check == false){
- return false;
- }else{
- $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
- function(data) {
- Calendar.UI.loadEvents();
- $('#choosecalendar_dialog').dialog('destroy').remove();
- Calendar.UI.Calendar.overview();
- });
- }
- },
- initscroll:function(){
+ initScroll:function(){
if(window.addEventListener)
- document.addEventListener('DOMMouseScroll', Calendar.UI.scrollcalendar);
+ document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar);
//}else{
- document.onmousewheel = Calendar.UI.scrollcalendar;
+ document.onmousewheel = Calendar.UI.scrollCalendar;
//}
},
- scrollcalendar:function(event){
+ scrollCalendar:function(event){
+ $('.tipsy').remove();
var direction;
if(event.detail){
if(event.detail < 0){
- direction = "top";
+ direction = 'top';
}else{
- direction = "down";
+ direction = 'down';
}
}
if (event.wheelDelta){
if(event.wheelDelta > 0){
- direction = "top";
+ direction = 'top';
}else{
- direction = "down";
+ direction = 'down';
}
}
- if(Calendar.UI.currentview == "onemonthview"){
- if(direction == "down"){
- Calendar.UI.updateDate("forward");
- }else{
- Calendar.UI.updateDate("backward");
- }
- }else if(Calendar.UI.currentview == "oneweekview"){
- if(direction == "down"){
- Calendar.UI.updateDate("forward");
- }else{
- Calendar.UI.updateDate("backward");
- }
+ var scroll = $(document).scrollTop(),
+ doc_height = $(document).height(),
+ win_height = $(window).height();
+ if(direction == 'down' && win_height == (doc_height - scroll)){
+ $('#calendar_holder').fullCalendar('next');
+ $(document).scrollTop(0);
+ event.preventDefault();
+ }else if (direction == 'top' && scroll == 0) {
+ $('#calendar_holder').fullCalendar('prev');
+ $(document).scrollTop(win_height);
+ event.preventDefault();
}
},
Calendar:{
@@ -510,8 +224,14 @@ Calendar={
{
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
- checkbox.checked = data == 1;
- Calendar.UI.loadEvents();
+ if (data.status == 'success'){
+ checkbox.checked = data.active == 1;
+ if (data.active == 1){
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }else{
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ }
+ }
});
},
newCalendar:function(object){
@@ -526,6 +246,46 @@ Calendar={
function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
+ deleteCalendar:function(calid){
+ var check = confirm("Do you really want to delete this calendar?");
+ if(check == false){
+ return false;
+ }else{
+ $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
+ function(data) {
+ if (data.status == 'success'){
+ var url = 'ajax/events.php?calendar_id='+calid;
+ $('#calendar_holder').fullCalendar('removeEventSource', url);
+ $('#choosecalendar_dialog').dialog('destroy').remove();
+ Calendar.UI.Calendar.overview();
+ }
+ });
+ }
+ },
+ submit:function(button, calendarid){
+ var displayname = $("#displayname_"+calendarid).val();
+ var active = $("#edit_active_"+calendarid+":checked").length;
+ var description = $("#description_"+calendarid).val();
+ var calendarcolor = $("#calendarcolor_"+calendarid).val();
+
+ var url;
+ if (calendarid == 'new'){
+ url = OC.filePath('calendar', 'ajax', 'createcalendar.php');
+ }else{
+ url = OC.filePath('calendar', 'ajax', 'updatecalendar.php');
+ }
+ $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
+ function(data){
+ if(data.status == 'success'){
+ $(button).closest('tr').prev().html(data.page).show().next().remove();
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }
+ }, 'json');
+ },
+ cancel:function(button, calendarid){
+ $(button).closest('tr').prev().show().next().remove();
+ },
colorPicker:function(container){
// based on jquery-colorpicker at jquery.webspirited.com
var obj = $('.colorpicker', container);
@@ -551,429 +311,233 @@ Calendar={
position: 'absolute',
left: -10000
});
- },
- submit:function(button, calendarid){
- var displayname = $("#displayname_"+calendarid).val();
- var active = $("#edit_active_"+calendarid+":checked").length;
- var description = $("#description_"+calendarid).val();
- var calendarcolor = $("#calendarcolor_"+calendarid).val();
-
- var url;
- if (calendarid == 'new'){
- url = "ajax/createcalendar.php";
- }else{
- url = "ajax/updatecalendar.php";
- }
- $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
- function(data){
- if(data.error == "true"){
- }else{
- $(button).closest('tr').prev().html(data.data).show().next().remove();
- Calendar.UI.loadEvents();
- }
- }, 'json');
- },
- cancel:function(button, calendarid){
- $(button).closest('tr').prev().show().next().remove();
- },
- },/*
- OneDay:{
- forward:function(){
- Calendar.Date.forward_day();
- },
- backward:function(){
- Calendar.Date.backward_day();
- },
- removeEvents:function(){
- $("#onedayview .calendar_row").empty();
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.formatDayShort() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort() + Calendar.space + Calendar.Date.current.getFullYear());
- $("#onedayview_today").html(Calendar.UI.formatDayLong() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort());
- Calendar.UI.addDateInfo('#onedayview_today', new Date(Calendar.Date.current));
- },
- showEvents:function(){
- Calendar.UI.createEventsForDate(Calendar.Date.current, 0);
- },
- getEventContainer:function(week, weekday, when){
- return $("#onedayview ." + when);
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + ' ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- },*/
- OneWeek:{
- forward:function(){
- Calendar.Date.forward_week();
- },
- backward:function(){
- Calendar.Date.backward_week();
- },
- removeEvents:function(){
- for( i = 0; i <= 6; i++) {
- $("#oneweekview ." + Calendar.UI.weekdays[i]).empty();
- }
- $("#oneweekview .thisday").removeClass("thisday");
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.cw_label + ": " + Calendar.Date.calw());
- var dates = this.generateDates();
- var today = new Date();
- for(var i = 0; i <= 6; i++){
- $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
- $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + "allday");
- $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- for(var ii = 0;ii <= 23; ii++){
- $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + String(ii) + ":00");
- $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- }
- if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
- $("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
- }
- Calendar.UI.addDateInfo('#oneweekview th.' + Calendar.UI.weekdays[i], dates[i]);
- }
- },
- showEvents:function(){
- var dates = this.generateDates();
- for(var weekday = 0; weekday <= 6; weekday++) {
- Calendar.UI.createEventsForDate(dates[weekday], 0);
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#oneweekview ." + Calendar.UI.weekdays[weekday] + "." + when);
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + ' ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- if(Calendar.firstdayofweek > dayofweek){
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
- }else{
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
- }
- for(var i = 0; i <= 6; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
- }
- return dates;
- },
- },/*
- FourWeeks:{
- forward:function(){
- Calendar.Date.forward_week();
- },
- backward:function(){
- Calendar.Date.backward_week();
- },
- removeEvents:function(){
- $('#fourweeksview .day.thisday').removeClass('thisday');
- $('#fourweeksview .day .events').empty();
- },
- renderCal:function(){
- var calw1 = Calendar.Date.calw();
- var calw2 = calw1 + 1;
- var calw3 = calw1 + 2;
- var calw4 = calw1 + 3;
- switch(calw1) {
- case 50:
- calw4 = 1;
- break;
- case 51:
- calw3 = 1;
- calw4 = 2;
- break;
- case 52:
- calw2 = 1;
- calw3 = 2;
- calw4 = 3;
- break;
- }
- var calwplusfour = calw4;
- var dates = this.generateDates();
- var week = 1;
- var weekday = 0;
- var today = new Date();
- for(var i = 0; i <= 27; i++){
- var dayofmonth = dates[i].getDate();
- var month = dates[i].getMonth();
- var year = dates[i].getFullYear();
- $("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
- if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
- $("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
- }
- Calendar.UI.addDateInfo('#fourweeksview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
- if(weekday == 6){
- weekday = 0;
- week++;
- }else{
- weekday++;
- }
- }
- $("#fourweeksview .week_1 .calw").html(calw1);
- $("#fourweeksview .week_2 .calw").html(calw2);
- $("#fourweeksview .week_3 .calw").html(calw3);
- $("#fourweeksview .week_4 .calw").html(calw4);
- $("#datecontrol_date").val(Calendar.UI.cws_label + ": " + Calendar.Date.calw() + " - " + calwplusfour);
- },
- showEvents:function(){
- var dates = this.generateDates();
- var weekdaynum = 0;
- var weeknum = 1;
- for(var i = 0; i <= 27; i++) {
- Calendar.UI.createEventsForDate(dates[i], weeknum);
- if(weekdaynum == 6){
- weekdaynum = 0;
- weeknum++;
- }else{
- weekdaynum++;
- }
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#fourweeksview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '' + Calendar.UI.formatTime(event['startdate']) + ' ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- date.setDate(date.getDate() - dayofweek + 1);
- for(var i = 0; i <= 27; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
- }
- return dates;
- },
- },*/
- OneMonth:{
- forward:function(){
- Calendar.Date.forward_month();
- },
- backward:function(){
- Calendar.Date.backward_month();
- },
- removeEvents:function(){
- $('#onemonthview .day.thisday').removeClass('thisday');
- $('#onemonthview .day .events').empty();
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.formatMonthLong() + Calendar.space + Calendar.Date.current.getFullYear());
- var cal = Calendar.Date.getnumberofdays(Calendar.Date.current.getFullYear());
- var monthview_dayofweek = Calendar.Date.current.getDay();
- var monthview_dayofmonth = Calendar.Date.current.getDate();
- for(var i = monthview_dayofmonth; i > 1; i--) {
- if(monthview_dayofweek == 0) {
- monthview_dayofweek = 6;
- } else {
- monthview_dayofweek--;
- }
- }
- $("#onemonthview .week_5").hide();
- $("#onemonthview .week_6").hide();
- this.rows = monthview_dayofweek + cal[Calendar.Date.current.getMonth()];
- this.rows = this.rows / 7;
- this.rows = Math.ceil(this.rows);
- var dates = this.generateDates();
- var week = 1;
- var weekday = 0;
- var today = new Date();
- for(var i = 0; i <= 41; i++){
- var dayofmonth = dates[i].getDate();
- var month = dates[i].getMonth();
- var year = dates[i].getFullYear();
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).attr('title', dayofmonth + "." + String(parseInt(month) + 1) + "." + year);
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
- }
- Calendar.UI.addDateInfo('#onemonthview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
- if(weekday == 6){
- weekday = 0;
- week++;
- }else{
- weekday++;
- }
- }
- if(this.rows == 4){
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("23%");
- }
- }
- if(this.rows == 5) {
- $("#onemonthview .week_5").show();
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("18%");
- }
- }
- if(this.rows == 6) {
- $("#onemonthview .week_5").show();
- $("#onemonthview .week_6").show();
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("14%");
- }
- }
- },
- showEvents:function(){
- var dates = this.generateDates();
- var weekdaynum = 0;
- var weeknum = 1;
- for(var i = 0; i <= 41; i++) {
- Calendar.UI.createEventsForDate(dates[i], weeknum);
- if(weekdaynum == 6){
- weekdaynum = 0;
- weeknum++;
- }else{
- weekdaynum++;
- }
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#onemonthview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '' + Calendar.UI.formatTime(event['startdate']) + ' ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- date.setDate(1);
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- this.rows++;
- }
- if(Calendar.firstdayofweek > dayofweek){
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
- }else{
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
- }
- for(var i = 0; i <= 41; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
- }
- return dates;
- },
- },
- List:{
- removeEvents:function(){
- this.eventContainer = $('#listview #events').empty();
- this.startdate = new Date();
- this.enddate = new Date();
- this.enddate.setDate(this.enddate.getDate());
- },
- renderCal:function(){
- var today = new Date();
- $('#datecontrol_date').val(this.formatDate(Calendar.Date.current));
- },
- showEvents:function(){
- this.renderMoreBefore();
- this.renderMoreAfter();
- },
- formatDate:function(date){
- return Calendar.UI.formatDayShort(date.getDay())
- + Calendar.space
- + date.getDate()
- + Calendar.space
- + Calendar.UI.formatMonthShort(date.getMonth())
- + Calendar.space
- + date.getFullYear();
- },
- createDay:function(date) {
- return $(document.createElement('div'))
- .addClass('day')
- .html(this.formatDate(date));
- },
- renderMoreBefore:function(){
- var date = Calendar.UI.List.startdate;
- for(var i = 0; i <= 13; i++) {
- if (Calendar.UI.getEventsForDate(date)) {
- Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
- Calendar.UI.createEventsForDate(date, 0);
- Calendar.UI.List.eventContainer.prepend(Calendar.UI.List.dayContainer);
- }
- date.setDate(date.getDate()-1);
- }
- var start = Calendar.UI.List.formatDate(date);
- $('#listview #more_before').html(String(Calendar.UI.more_before).replace('{startdate}', start));
- },
- renderMoreAfter:function(){
- var date = Calendar.UI.List.enddate;
- for(var i = 0; i <= 13; i++) {
- if (Calendar.UI.getEventsForDate(date)) {
- Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
- Calendar.UI.createEventsForDate(date, 0);
- Calendar.UI.List.eventContainer.append(Calendar.UI.List.dayContainer);
- }
- date.setDate(date.getDate()+1);
- }
- var end = Calendar.UI.List.formatDate(date);
- $('#listview #more_after').html(String(Calendar.UI.more_after).replace('{enddate}', end));
- },
- getEventContainer:function(week, weekday, when){
- return this.dayContainer;
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + ' ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
+ }
}
}
}
+$.fullCalendar.views.list = ListView;
+function ListView(element, calendar) {
+ var t = this;
+
+ // imports
+ jQuery.fullCalendar.views.month.call(t, element, calendar);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var eventElementHandlers = t.eventElementHandlers;
+ var reportEventElement = t.reportEventElement;
+ var formatDate = calendar.formatDate;
+ var formatDates = calendar.formatDates;
+ var addDays = $.fullCalendar.addDays;
+ var cloneDate = $.fullCalendar.cloneDate;
+ function skipWeekend(date, inc, excl) {
+ inc = inc || 1;
+ while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
+ addDays(date, inc);
+ }
+ return date;
+ }
+
+ // overrides
+ t.name='list';
+ t.render=render;
+ t.renderEvents=renderEvents;
+ t.setHeight=setHeight;
+ t.setWidth=setWidth;
+ t.clearEvents=clearEvents;
+
+ function setHeight(height, dateChanged) {
+ }
+
+ function setWidth(width) {
+ }
+
+ function clearEvents() {
+ this.reportEventClear();
+ }
+
+ // main
+ function sortEvent(a, b) {
+ return a.start - b.start;
+ }
+
+ function render(date, delta) {
+ if (!t.start){
+ t.start = addDays(cloneDate(date, true), -7);
+ t.end = addDays(cloneDate(date, true), 7);
+ }
+ if (delta) {
+ if (delta < 0){
+ addDays(t.start, -7);
+ if (!opt('weekends')) {
+ skipWeekend(t.start, delta < 0 ? -1 : 1);
+ }
+ }else{
+ addDays(t.end, 7);
+ if (!opt('weekends')) {
+ skipWeekend(t.end, delta < 0 ? -1 : 1);
+ }
+ }
+ }
+ t.title = formatDates(
+ t.start,
+ t.end,
+ opt('titleFormat', 'week')
+ );
+ t.visStart = cloneDate(t.start);
+ t.visEnd = cloneDate(t.end);
+ }
+
+ function eventsOfThisDay(events, theDate) {
+ var start = cloneDate(theDate, true);
+ var end = addDays(cloneDate(start), 1);
+ var retArr = new Array();
+ for (i in events) {
+ var event_end = t.eventEnd(events[i]);
+ if (events[i].start < end && event_end >= start) {
+ retArr.push(events[i]);
+ }
+ }
+ return retArr;
+ }
+
+ function renderEvent(event) {
+ if (event.allDay) { //all day event
+ var time = opt('allDayText');
+ }
+ else {
+ var time = formatDates(event.start, event.end, opt('timeFormat', 'agenda'));
+ }
+ var classes = ['fc-event', 'fc-list-event'];
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ var html = '' +
+ ' ' +
+ '' +
+ time +
+ ' ' +
+ ' ' +
+ '' +
+ '' +
+ '' +
+ event.title +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ';
+ return html;
+ }
+
+ function renderDay(date, events) {
+ var dayRows = $('' +
+ '' +
+ '' +
+ formatDate(date, opt('titleFormat', 'day')) +
+ ' ' +
+ ' ' +
+ ' ');
+ for (i in events) {
+ var event = events[i];
+ var eventElement = $(renderEvent(event));
+ triggerRes = trigger('eventRender', event, event, eventElement);
+ if (triggerRes === false) {
+ eventElement.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ eventElement.remove();
+ eventElement = $(triggerRes);
+ }
+ $.merge(dayRows, eventElement);
+ eventElementHandlers(event, eventElement);
+ reportEventElement(event, eventElement);
+ }
+ }
+ return dayRows;
+ }
+
+ function renderEvents(events, modifiedEventId) {
+ events = events.sort(sortEvent);
+
+ var table = $('');
+ var total = events.length;
+ if (total > 0) {
+ var date = cloneDate(t.visStart);
+ while (date <= t.visEnd) {
+ var dayEvents = eventsOfThisDay(events, date);
+ if (dayEvents.length > 0) {
+ table.append(renderDay(date, dayEvents));
+ }
+ date=addDays(date, 1);
+ }
+ }
+
+ this.element.html(table);
+ }
+}
$(document).ready(function(){
- $('#listview #more_before').click(Calendar.UI.List.renderMoreBefore);
- $('#listview #more_after').click(Calendar.UI.List.renderMoreAfter);
- Calendar.UI.initscroll();
+ Calendar.UI.initScroll();
+ $('#calendar_holder').fullCalendar({
+ header: false,
+ firstDay: 1,
+ editable: true,
+ defaultView: defaultView,
+ timeFormat: {
+ agenda: agendatime,
+ '': defaulttime
+ },
+ titleFormat: {
+ list: 'yyyy/MMM/d dddd'
+ },
+ axisFormat: defaulttime,
+ monthNames: monthNames,
+ monthNamesShort: monthNamesShort,
+ dayNames: dayNames,
+ dayNamesShort: dayNamesShort,
+ allDayText: allDayText,
+ viewDisplay: function(view) {
+ $('#datecontrol_date').html(view.title);
+ $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name);
+ },
+ selectable: true,
+ selectHelper: true,
+ select: Calendar.UI.newEvent,
+ eventClick: Calendar.UI.editEvent,
+ eventDrop: Calendar.UI.moveEvent,
+ eventResize: Calendar.UI.resizeEvent,
+ eventRender: function(event, element) {
+ element.tipsy({
+ className: 'tipsy-event',
+ opacity: 0.9,
+ gravity:$.fn.tipsy.autoBounds(150, 's'),
+ fade:true,
+ delayIn: 400,
+ html:true,
+ title:function() {
+ return Calendar.UI.getEventPopupText(event);
+ }
+ });
+ },
+ eventSources: eventSources
+ });
+ $('#oneweekview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'agendaWeek');
+ });
+ $('#onemonthview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'month');
+ });
+ $('#listview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'list');
+ });
+ $('#today_input').click(function(){
+ $('#calendar_holder').fullCalendar('today');
+ });
+ $('#datecontrol_left').click(function(){
+ $('#calendar_holder').fullCalendar('prev');
+ });
+ $('#datecontrol_right').click(function(){
+ $('#calendar_holder').fullCalendar('next');
+ });
});
-//event vars
-Calendar.UI.loadEvents();
diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js
new file mode 100755
index 0000000000..acea17c026
--- /dev/null
+++ b/apps/calendar/js/geo.js
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2011 Georg Ehrke
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(function(position) {
+ $.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
+ function(data){
+ if (data.status == 'success'){
+ $('#notification').html(data.message);
+ $('#notification').slideDown();
+ window.setTimeout(function(){$('#notification').slideUp();}, 5000);
+ }else{
+ console.log('Can\'t set new timezone.');
+ }
+ });
+ });
+}
\ No newline at end of file
diff --git a/apps/calendar/l10n/xgettextfiles b/apps/calendar/l10n/xgettextfiles
index 4cc636436b..27b8e45719 100644
--- a/apps/calendar/l10n/xgettextfiles
+++ b/apps/calendar/l10n/xgettextfiles
@@ -1,7 +1,11 @@
../appinfo/app.php
+../lib/object.php
../templates/calendar.php
-../templates/part.editevent.php
-../templates/part.eventinfo.php
-../templates/part.newevent.php
../templates/part.choosecalendar.php
-../js/calendar.js
+../templates/part.choosecalendar.rowfields.php
+../templates/part.editcalendar.php
+../templates/part.editevent.php
+../templates/part.eventform.php
+../templates/part.import.php
+../templates/part.newevent.php
+../templates/settings.php
\ No newline at end of file
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
new file mode 100644
index 0000000000..b023d531aa
--- /dev/null
+++ b/apps/calendar/lib/app.php
@@ -0,0 +1,82 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * This class manages our app actions
+ */
+OC_Calendar_App::$l10n = new OC_L10N('calendar');
+class OC_Calendar_App{
+ public static $l10n;
+
+ public static function getCalendar($id){
+ $calendar = OC_Calendar_Calendar::find( $id );
+ if( $calendar === false || $calendar['userid'] != OC_User::getUser()){
+ OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar'))));
+ exit();
+ }
+ return $calendar;
+ }
+
+ public static function getEventObject($id){
+ $event_object = OC_Calendar_Object::find( $id );
+ if( $event_object === false ){
+ OC_JSON::error();
+ exit();
+ }
+
+ self::getCalendar( $event_object['calendarid'] );//access check
+ return $event_object;
+ }
+
+ public static function getVCalendar($id){
+ $event_object = self::getEventObject( $id );
+
+ $vcalendar = OC_VObject::parse($event_object['calendardata']);
+ // Check if the vcalendar is valid
+ if(is_null($vcalendar)){
+ OC_JSON::error();
+ exit();
+ }
+ return $vcalendar;
+ }
+
+ public static function isNotModified($vevent, $lastmodified)
+ {
+ $last_modified = $vevent->__get('LAST-MODIFIED');
+ if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){
+ OC_JSON::error(array('modified'=>true));
+ exit;
+ }
+ }
+
+ public static function getCategoryOptions()
+ {
+ return array(
+ self::$l10n->t('Birthday'),
+ self::$l10n->t('Business'),
+ self::$l10n->t('Call'),
+ self::$l10n->t('Clients'),
+ self::$l10n->t('Deliverer'),
+ self::$l10n->t('Holidays'),
+ self::$l10n->t('Ideas'),
+ self::$l10n->t('Journey'),
+ self::$l10n->t('Jubilee'),
+ self::$l10n->t('Meeting'),
+ self::$l10n->t('Other'),
+ self::$l10n->t('Personal'),
+ self::$l10n->t('Projects'),
+ self::$l10n->t('Questions'),
+ self::$l10n->t('Work'),
+ );
+ }
+
+ public static function getRepeatOptions()
+ {
+ OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ }
+}
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index c19c0e73c0..ea60526a5b 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -82,7 +82,7 @@ class OC_Calendar_Calendar{
* @param integer $id
* @return associative array
*/
- public static function findCalendar($id){
+ public static function find($id){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' );
$result = $stmt->execute(array($id));
@@ -111,7 +111,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendar');
}
/**
@@ -131,7 +131,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendars');
}
/**
@@ -148,7 +148,7 @@ class OC_Calendar_Calendar{
*/
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){
// Need these ones for checking uri
- $calendar = self::findCalendar($id);
+ $calendar = self::find($id);
// Keep old stuff
if(is_null($name)) $name = $calendar['name'];
@@ -240,4 +240,12 @@ class OC_Calendar_Calendar{
'ecc255', // dark yellow
);
}
+ public static function getEventSourceInfo($calendar){
+ return array(
+ 'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
+ 'backgroundColor' => '#'.$calendar['calendarcolor'],
+ 'borderColor' => '#888',
+ 'textColor' => 'black',
+ );
+ }
}
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 0c3e497d4f..58fe60611c 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -30,6 +30,36 @@ class OC_Calendar_Object{
return $calendarobjects;
}
+ /**
+ * @brief Returns all objects of a calendar between $start and $end
+ * @param integer $id
+ * @param DateTime $start
+ * @param DateTime $end
+ * @return array
+ *
+ * The objects are associative arrays. You'll find the original vObject
+ * in ['calendardata']
+ */
+ public static function allInPeriod($id, $start, $end){
+ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?'
+ .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)'
+ .' OR (enddate >= ? AND enddate <= ? AND repeating = 0)'
+ .' OR (startdate <= ? AND repeating = 1))' );
+ $start = self::getUTCforMDB($start);
+ $end = self::getUTCforMDB($end);
+ $result = $stmt->execute(array($id,
+ $start, $end,
+ $start, $end,
+ $end));
+
+ $calendarobjects = array();
+ while( $row = $result->fetchRow()){
+ $calendarobjects[] = $row;
+ }
+
+ return $calendarobjects;
+ }
+
/**
* @brief Returns an object
* @param integer $id
@@ -62,7 +92,7 @@ class OC_Calendar_Object{
* @return insertid
*/
public static function add($id,$data){
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
@@ -78,7 +108,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
@@ -89,7 +119,7 @@ class OC_Calendar_Object{
* @return insertid
*/
public static function addFromDAVData($id,$uri,$data){
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
@@ -97,7 +127,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
@@ -109,7 +139,7 @@ class OC_Calendar_Object{
public static function edit($id, $data){
$oldobject = self::find($id);
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@@ -130,7 +160,7 @@ class OC_Calendar_Object{
public static function editFromDAVData($cid,$uri,$data){
$oldobject = self::findWhereDAVDataIs($cid,$uri);
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@@ -198,7 +228,7 @@ class OC_Calendar_Object{
// Child to use
$children = 0;
$use = null;
- foreach($object->children as &$property){
+ foreach($object->children as $property){
if($property->name == 'VEVENT'){
$children++;
$thisone = true;
@@ -229,12 +259,12 @@ class OC_Calendar_Object{
// one VTODO per object)
break;
}
- } unset($property);
+ }
// find the data
if(!is_null($use)){
$return[0] = $use->name;
- foreach($use->children as &$property){
+ foreach($use->children as $property){
if($property->name == 'DTSTART'){
$return[1] = self::getUTCforMDB($property->getDateTime());
}
@@ -250,7 +280,7 @@ class OC_Calendar_Object{
elseif($property->name == 'UID'){
$return[5] = $property->value;
}
- } unset($property);
+ }
}
// More than one child means reoccuring!
@@ -272,20 +302,6 @@ class OC_Calendar_Object{
return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset());
}
- /**
- * @brief Parses the VObject
- * @param string VObject as string
- * @returns Sabre_VObject or null
- */
- public static function parse($data){
- try {
- $calendar = Sabre_VObject_Reader::read($data);
- return $calendar;
- } catch (Exception $e) {
- return null;
- }
- }
-
public static function getDTEndFromVEvent($vevent)
{
if ($vevent->DTEND) {
@@ -351,7 +367,7 @@ class OC_Calendar_Object{
$errarr['title'] = 'true';
$errnum++;
}
- $calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
+ $calendar = OC_Calendar_Calendar::find($request['calendar']);
if($calendar['userid'] != OC_User::getUser()){
$errarr['cal'] = 'true';
$errnum++;
@@ -398,7 +414,7 @@ class OC_Calendar_Object{
$errarr['endbeforestart'] = 'true';
$errnum++;
}
- if($fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
+ if(!$allday && $fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
list($tohours, $tominutes) = explode(':', $request['totime']);
list($fromhours, $fromminutes) = explode(':', $request['fromtime']);
if($tohours < $fromhours){
@@ -427,22 +443,16 @@ class OC_Calendar_Object{
public static function createVCalendarFromRequest($request)
{
- $vcalendar = new Sabre_VObject_Component('VCALENDAR');
+ $vcalendar = new OC_VObject('VCALENDAR');
$vcalendar->add('PRODID', 'ownCloud Calendar');
$vcalendar->add('VERSION', '2.0');
- $now = new DateTime();
-
- $vevent = new Sabre_VObject_Component('VEVENT');
+ $vevent = new OC_VObject('VEVENT');
$vcalendar->add($vevent);
- $created = new Sabre_VObject_Element_DateTime('CREATED');
- $created->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->add($created);
-
- $uid = self::createUID();
- $vevent->add('UID',$uid);
+ $vevent->setDateTime('CREATED', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setUID();
return self::updateVCalendarFromRequest($request, $vcalendar);
}
@@ -450,12 +460,14 @@ class OC_Calendar_Object{
{
$title = $request["title"];
$location = $request["location"];
- $categories = isset($request["categories"]) ? $request["categories"] : null;
+ $categories = isset($request["categories"]) ? $request["categories"] : array();
$allday = isset($request["allday"]);
$from = $request["from"];
- $fromtime = $request["fromtime"];
$to = $request["to"];
- $totime = $request["totime"];
+ if (!$allday){
+ $fromtime = $request['fromtime'];
+ $totime = $request['totime'];
+ }
$description = $request["description"];
//$repeat = $request["repeat"];
/*switch($request["repeatfreq"]){
@@ -476,55 +488,32 @@ class OC_Calendar_Object{
}*/
$repeat = "false";
- $now = new DateTime();
- $vevent = $vcalendar->VEVENT[0];
+ $vevent = $vcalendar->VEVENT;
- $last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
- $last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->__set('LAST-MODIFIED', $last_modified);
-
- $dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP');
- $dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->DTSTAMP = $dtstamp;
-
- $vevent->SUMMARY = $title;
+ $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setString('SUMMARY', $title);
$dtstart = new Sabre_VObject_Element_DateTime('DTSTART');
$dtend = new Sabre_VObject_Element_DateTime('DTEND');
if($allday){
$start = new DateTime($from);
$end = new DateTime($to.' +1 day');
- $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::DATE);
- $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::DATE);
+ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::DATE);
+ $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::DATE);
}else{
- $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
+ $timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$timezone = new DateTimeZone($timezone);
$start = new DateTime($from.' '.$fromtime, $timezone);
$end = new DateTime($to.' '.$totime, $timezone);
- $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::LOCALTZ);
- $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::LOCALTZ);
+ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::LOCALTZ);
+ $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::LOCALTZ);
}
- $vevent->DTSTART = $dtstart;
- $vevent->DTEND = $dtend;
unset($vevent->DURATION);
- if($location != ""){
- $vevent->LOCATION = $location;
- }else{
- unset($vevent->LOCATION);
- }
-
- if($description != ""){
- $vevent->DESCRIPTION = $description;
- }else{
- unset($vevent->DESCRIPTION);
- }
-
- if(!empty($categories)){
- $vevent->CATEGORIES = join(',', $categories);
- }else{
- unset($vevent->CATEGORIES);
- }
+ $vevent->setString('LOCATION', $location);
+ $vevent->setString('DESCRIPTION', $description);
+ $vevent->setString('CATEGORIES', join(',', $categories));
/*if($repeat == "true"){
$vevent->RRULE = $repeat;
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
new file mode 100644
index 0000000000..41faf49a51
--- /dev/null
+++ b/apps/calendar/lib/search.php
@@ -0,0 +1,26 @@
+ 0){
+ $searchquery = explode(' ', $query);
+ }else{
+ $searchquery[] = $query;
+ }
+ foreach($calendars as $calendar){
+ $objects = OC_Calendar_Object::all($calendar['id']);
+ foreach($objects as $object){
+ if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type
+ $results[]=new OC_Search_Result($object['summary'],'','#','Cal.');
+ }
+ }
+ }
+ return $results;
+ }
+}
+new OC_Search_Provider_Calendar();
\ No newline at end of file
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
old mode 100644
new mode 100755
index 317bb17ddb..2003b7efc4
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -1,217 +1,50 @@
- $l->t('All day'),
- 0 => '0',
- 1 => '1',
- 2 => '2',
- 3 => '3',
- 4 => '4',
- 5 => '5',
- 6 => '6',
- 7 => '7',
- 8 => '8',
- 9 => '9',
- 10 => '10',
- 11 => '11',
- 12 => '12',
- 13 => '13',
- 14 => '14',
- 15 => '15',
- 16 => '16',
- 17 => '17',
- 18 => '18',
- 19 => '19',
- 20 => '20',
- 21 => '21',
- 22 => '22',
- 23 => '23',
-);
-$hoursampm = array(
- 'allday' => $l->t('All day'),
- 0 => '12 a.m.',
- 1 => '1 a.m.',
- 2 => '2 a.m.',
- 3 => '3 a.m.',
- 4 => '4 a.m.',
- 5 => '5 a.m.',
- 6 => '6 a.m.',
- 7 => '7 a.m.',
- 8 => '8 a.m.',
- 9 => '9 a.m.',
- 10 => '10 a.m.',
- 11 => '11 a.m.',
- 12 => '12 p.m.',
- 13 => '1 p.m.',
- 14 => '2 p.m.',
- 15 => '3 p.m.',
- 16 => '4 p.m.',
- 17 => '5 p.m.',
- 18 => '6 p.m.',
- 19 => '7 p.m.',
- 20 => '8 p.m.',
- 21 => '9 p.m.',
- 22 => '10 p.m.',
- 23 => '11 p.m.',
-);
-if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){
- $hours = $hours24;
-}else{
- $hours = $hoursampm;
-}
-$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
-$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
-$weekdays = array();
-for($i = 0;$i <= 6; $i++){
- $weekdays[$i] = $weekdaynames[$dayforgenerator];
- if($dayforgenerator == 6){
- $dayforgenerator = 0;
- }else{
- $dayforgenerator++;
- }
-}
-$weekendjson = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}');
-$weekend = json_decode($weekendjson, true);
-$weekenddays = array("sunday"=>$weekend["Sunday"], "monday"=>$weekend["Monday"], "tuesday"=>$weekend["Tuesday"], "wednesday"=>$weekend["Wednesday"], "thursday"=>$weekend["Thursday"], "friday"=>$weekend["Friday"], "saturday"=>$weekend["Saturday"]);
-?>
-
-
+
-
-
-
-
- t("Time");?>
-
-
-
-
- $time_label): ?>
-
-
-
-
-
-
-
-
-
-
-
-
- t("Time");?>
- $weekday): ?>
- " onclick="Calendar.UI.newEvent('#oneweekview th.');">
-
-
-
-
- $time_label): ?>
-
-
- $weekday): ?>
- " onclick="Calendar.UI.newEvent('#oneweekview th.', '');">
-
-
-
-
-
-
-
-
-
-
- t("Week");?>
- $weekday): ?>
- t(ucfirst($weekday)) ?>
-
-
-
-
-
-
-
- $weekday): ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $weekday): ?>
- ">t(ucfirst($weekday));?>
-
-
-
-
-
-
- $weekday): ?>
- " onclick="Calendar.UI.newEvent('#onemonthview .week_ .')">
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php
index db0c71252b..a789be45a4 100644
--- a/apps/calendar/templates/part.choosecalendar.rowfields.php
+++ b/apps/calendar/templates/part.choosecalendar.rowfields.php
@@ -1,4 +1,4 @@
";
echo "" . $_['calendar']["displayname"] . " ";
- echo "t("CalDav Link") . "\" class=\"action\"> t("Download") . "\" class=\"action\"> t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"> t("Delete") . "\" class=\"action\"> ";
+ echo "t("CalDav Link") . "\" class=\"action\"> t("Download") . "\" class=\"action\"> t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"> t("Delete") . "\" class=\"action\"> ";
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index ae969f2dc3..b3acfc4a07 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -1,6 +1,7 @@
- inc("part.addcardform"); ?>
+ inc("part.details");
+ }
+ else{
+ echo $this->inc("part.addcardform");
+ }
+ ?>
diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php
index 8e482cc4eb..627053547a 100644
--- a/apps/contacts/templates/part.addcardform.php
+++ b/apps/contacts/templates/part.addcardform.php
@@ -7,9 +7,7 @@
t('Group'); ?>
-
-
-
+ 'id', 'label'=>'displayname')); ?>
@@ -19,7 +17,7 @@
t('Name'); ?>
-
+
t('Organization'); ?>
@@ -45,15 +43,8 @@
t('Type'); ?>
-
- t('Home'); ?>
- t('Mobile'); ?>
- t('Work'); ?>
- t('Text'); ?>
- t('Voice'); ?>
- t('Fax'); ?>
- t('Video'); ?>
- t('Pager'); ?>
+
+
@@ -67,8 +58,7 @@
t('Type'); ?>
- t('Work'); ?>
- t('Home'); ?>
+
@@ -81,19 +71,19 @@
t('Street'); ?>
-
+
t('City'); ?>
-
+
t('Region'); ?>
-
+
t('Zipcode'); ?>
-
+
t('Country'); ?>
diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php
index e9fa8356e8..afad0b7f64 100644
--- a/apps/contacts/templates/part.details.php
+++ b/apps/contacts/templates/part.details.php
@@ -1,5 +1,5 @@
-
+ inc('part.property.FN', array('property' => $_['details']['FN'][0])); ?>
@@ -27,24 +27,21 @@
- t('Address'); ?>
- t('Telephone'); ?>
- t('Email'); ?>
- t('Organization'); ?>
+
+
+
-
-
+
-
- t('Home'); ?>
- t('Mobile'); ?>
- t('Work'); ?>
- t('Text'); ?>
- t('Voice'); ?>
- t('Fax'); ?>
- t('Video'); ?>
- t('Pager'); ?>
+
+
diff --git a/apps/contacts/templates/part.property.FN.php b/apps/contacts/templates/part.property.FN.php
new file mode 100644
index 0000000000..83cef94e30
--- /dev/null
+++ b/apps/contacts/templates/part.property.FN.php
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php
index 4bc3a4d85f..d930a9ca99 100644
--- a/apps/contacts/templates/part.property.php
+++ b/apps/contacts/templates/part.property.php
@@ -20,11 +20,23 @@
-
t('Phone'); ?>
+
t('Preferred').' ' : '' ?>t('Phone'); ?>
-
- (t(ucwords(str_replace('cell','mobile',strtolower($_['property']['parameters']['TYPE'])))); ?>)
+
+t(ucwords(strtolower($type)));
+ }
+ endforeach;
+ $label = join(' ', $types);
+?>
+ ()
@@ -34,7 +46,16 @@
t('Address'); ?>
- (t(ucwords($_['property']['parameters']['TYPE'])); ?>)
+t(ucwords(strtolower($type)));
+ }
+?>
+ ()
diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php
index eb8a67a8aa..8635d7db1c 100644
--- a/apps/contacts/templates/part.setpropertyform.php
+++ b/apps/contacts/templates/part.setpropertyform.php
@@ -1,10 +1,17 @@
-
-
diff --git a/apps/external/ajax/seturls.php b/apps/external/ajax/seturls.php
index c8e9775454..e994385a19 100644
--- a/apps/external/ajax/seturls.php
+++ b/apps/external/ajax/seturls.php
@@ -8,16 +8,16 @@
require_once('../../../lib/base.php');
OC_Util::checkAdminUser();
-if(isset($_POST['s1name'])) OC_Config::setValue( 'external-site1name', $_POST['s1name'] );
-if(isset($_POST['s1url'])) OC_Config::setValue( 'external-site1url', $_POST['s1url'] );
-if(isset($_POST['s2name'])) OC_Config::setValue( 'external-site2name', $_POST['s2name'] );
-if(isset($_POST['s2url'])) OC_Config::setValue( 'external-site2url', $_POST['s2url'] );
-if(isset($_POST['s3name'])) OC_Config::setValue( 'external-site3name', $_POST['s3name'] );
-if(isset($_POST['s3url'])) OC_Config::setValue( 'external-site3url', $_POST['s3url'] );
-if(isset($_POST['s4name'])) OC_Config::setValue( 'external-site4name', $_POST['s4name'] );
-if(isset($_POST['s4url'])) OC_Config::setValue( 'external-site4url', $_POST['s4url'] );
-if(isset($_POST['s5name'])) OC_Config::setValue( 'external-site5name', $_POST['s5name'] );
-if(isset($_POST['s5url'])) OC_Config::setValue( 'external-site5url', $_POST['s5url'] );
+if(isset($_POST['s1name'])) OC_Appconfig::setValue( 'external','site1name', $_POST['s1name'] );
+if(isset($_POST['s1url'])) OC_Appconfig::setValue( 'external','site1url', $_POST['s1url'] );
+if(isset($_POST['s2name'])) OC_Appconfig::setValue( 'external','site2name', $_POST['s2name'] );
+if(isset($_POST['s2url'])) OC_Appconfig::setValue( 'external','site2url', $_POST['s2url'] );
+if(isset($_POST['s3name'])) OC_Appconfig::setValue( 'external','site3name', $_POST['s3name'] );
+if(isset($_POST['s3url'])) OC_Appconfig::setValue( 'external','site3url', $_POST['s3url'] );
+if(isset($_POST['s4name'])) OC_Appconfig::setValue( 'external','site4name', $_POST['s4name'] );
+if(isset($_POST['s4url'])) OC_Appconfig::setValue( 'external','site4url', $_POST['s4url'] );
+if(isset($_POST['s5name'])) OC_Appconfig::setValue( 'external','site5name', $_POST['s5name'] );
+if(isset($_POST['s5url'])) OC_Appconfig::setValue( 'external','site5url', $_POST['s5url'] );
echo 'true';
diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php
index df14954d86..0f536cbf41 100644
--- a/apps/external/appinfo/app.php
+++ b/apps/external/appinfo/app.php
@@ -25,13 +25,13 @@ OC_APP::registerAdmin('external','settings');
OC_App::register( array( 'order' => 70, 'id' => 'external', 'name' => 'External' ));
-if(OC_Config::getValue( "external-site1name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index1', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=1', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site1name", '' )));
+if(OC_Appconfig::getValue( "external","site1name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index1', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=1', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site1name", '' )));
-if(OC_Config::getValue( "external-site2name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index2', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=2', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site2name", '' )));
+if(OC_Appconfig::getValue( "external","site2name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index2', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=2', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site2name", '' )));
-if(OC_Config::getValue( "external-site3name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index3', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=3', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site3name", '' )));
+if(OC_Appconfig::getValue( "external","site3name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index3', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=3', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site3name", '' )));
-if(OC_Config::getValue( "external-site4name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index4', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=4', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site4name", '' )));
+if(OC_Appconfig::getValue( "external","site4name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index4', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=4', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site4name", '' )));
-if(OC_Config::getValue( "external-site5name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index5', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=5', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site5name", '' )));
+if(OC_Appconfig::getValue( "external","site5name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index5', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=5', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site5name", '' )));
diff --git a/apps/external/index.php b/apps/external/index.php
index 116e16d909..86b19abc10 100644
--- a/apps/external/index.php
+++ b/apps/external/index.php
@@ -35,7 +35,7 @@ if(isset($_GET['id'])){
$id=$_GET['id'];
$id = (int) $id;
- $url=OC_Config::getValue( "external-site".$id."url", '' );
+ $url=OC_Appconfig::getValue( "external","site".$id."url", '' );
OC_App::setActiveNavigationEntry( 'external_index'.$id );
$tmpl = new OC_Template( 'external', 'frame', 'user' );
diff --git a/apps/external/settings.php b/apps/external/settings.php
index ad33c16e1b..3e0c342512 100644
--- a/apps/external/settings.php
+++ b/apps/external/settings.php
@@ -6,17 +6,17 @@ OC_Util::addScript( "external", "admin" );
$tmpl = new OC_Template( 'external', 'settings');
- $tmpl->assign('s1name',OC_Config::getValue( "external-site1name", '' ));
- $tmpl->assign('s2name',OC_Config::getValue( "external-site2name", '' ));
- $tmpl->assign('s3name',OC_Config::getValue( "external-site3name", '' ));
- $tmpl->assign('s4name',OC_Config::getValue( "external-site4name", '' ));
- $tmpl->assign('s5name',OC_Config::getValue( "external-site5name", '' ));
+ $tmpl->assign('s1name',OC_Appconfig::getValue( "external","site1name", '' ));
+ $tmpl->assign('s2name',OC_Appconfig::getValue( "external","site2name", '' ));
+ $tmpl->assign('s3name',OC_Appconfig::getValue( "external","site3name", '' ));
+ $tmpl->assign('s4name',OC_Appconfig::getValue( "external","site4name", '' ));
+ $tmpl->assign('s5name',OC_Appconfig::getValue( "external","site5name", '' ));
- $tmpl->assign('s1url',OC_Config::getValue( "external-site1url", '' ));
- $tmpl->assign('s2url',OC_Config::getValue( "external-site2url", '' ));
- $tmpl->assign('s3url',OC_Config::getValue( "external-site3url", '' ));
- $tmpl->assign('s4url',OC_Config::getValue( "external-site4url", '' ));
- $tmpl->assign('s5url',OC_Config::getValue( "external-site5url", '' ));
+ $tmpl->assign('s1url',OC_Appconfig::getValue( "external","site1url", '' ));
+ $tmpl->assign('s2url',OC_Appconfig::getValue( "external","site2url", '' ));
+ $tmpl->assign('s3url',OC_Appconfig::getValue( "external","site3url", '' ));
+ $tmpl->assign('s4url',OC_Appconfig::getValue( "external","site4url", '' ));
+ $tmpl->assign('s5url',OC_Appconfig::getValue( "external","site5url", '' ));
return $tmpl->fetchPage();
?>
diff --git a/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css b/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
index 030497750b..1dfd9b95d3 100644
--- a/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
+++ b/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
@@ -35,7 +35,7 @@
left: 0;
width: 40px;
height: 480px;
- background-image: url('../img/fancybox/fancybox.png');
+ background-image: url('../img/fancybox.png');
}
#fancybox-overlay {
@@ -282,7 +282,7 @@
#fancybox-title-over {
padding: 10px;
- background-image: url('../img/fancybox/fancy_title_over.png');
+ background-image: url('../img/fancy_title_over.png');
display: block;
}
@@ -306,7 +306,7 @@
#fancybox-title-float-left {
padding: 0 0 0 15px;
- background: url('../img/fancybox/fancybox.png') -40px -90px no-repeat;
+ background: url('../img/fancybox.png') -40px -90px no-repeat;
}
#fancybox-title-float-main {
@@ -314,25 +314,25 @@
line-height: 29px;
font-weight: bold;
padding: 0 0 3px 0;
- background: url('../img/fancybox/fancybox-x.png') 0px -40px;
+ background: url('../img/fancybox-x.png') 0px -40px;
}
#fancybox-title-float-right {
padding: 0 0 0 15px;
- background: url('../img/fancybox/fancybox.png') -55px -90px no-repeat;
+ background: url('../img/fancybox.png') -55px -90px no-repeat;
}
/* IE6 */
-.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_close.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_nav_left.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_nav_right.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
-.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
+.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_left.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_main.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
height: expression(this.parentNode.clientHeight + "px");
@@ -343,17 +343,17 @@
top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
}
-#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); }
+#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_loading.png', sizingMethod='scale'); }
/* IE6, IE7, IE8 */
.fancybox-ie .fancybox-bg { background: transparent !important; }
-.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_n.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_ne.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_e.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_se.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_s.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_sw.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_w.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_nw.png', sizingMethod='scale'); }
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index 075ec043ea..51fda6aed4 100644
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -1,5 +1,5 @@
';
html += '
';
if (filename) {
- $('tr[data-file="'+filename+'"]').addClass('mouseOver');
- $(html).appendTo($('tr[data-file="'+filename+'"] td.filename'));
+ $('tr').filterAttr('data-file',filename).addClass('mouseOver');
+ $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename'));
} else {
$(html).appendTo($('thead .share'));
}
@@ -223,7 +224,7 @@ function addUser(uid_shared_with, permissions, parentFolder) {
var user = ' ';
user += ' ';
user += uid_shared_with;
- user += ' ';
+ user += ' ';
user += 'can edit ';
user += ' ';
}
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index faf4e68d9b..d78e273bf3 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -285,7 +285,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
public function is_writeable($path) {
- if ($path == "" || $path == "/" || OC_Share::getPermissions($this->datadir.$path) & OC_Share::WRITE) {
+ if($path == "" || $path == "/"){
+ return false;
+ }elseif (OC_Share::getPermissions($this->datadir.$path) & OC_Share::WRITE) {
return true;
} else {
return false;
diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php
index 610f761b72..9413b54718 100644
--- a/apps/gallery/ajax/createAlbum.php
+++ b/apps/gallery/ajax/createAlbum.php
@@ -3,8 +3,7 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
-$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")');
-$stmt->execute(array());
+OC_Gallery_Album::create(OC_User::getUser(), $_GET['album_name']);
OC_JSON::success(array('name' => $_GET['album_name']));
diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php
index 98d92c5f31..7454b18eda 100644
--- a/apps/gallery/ajax/getAlbums.php
+++ b/apps/gallery/ajax/getAlbums.php
@@ -4,13 +4,12 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
$a = array();
-$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner LIKE ?');
-$result = $stmt->execute(array(OC_User::getUser()));
+$result = OC_Gallery_Album::find(OC_User::getUser());
while ($r = $result->fetchRow()) {
$album_name = $r['album_name'];
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?');
- $tmp_res = $stmt->execute(array($r['album_id']));
+ $tmp_res = OC_Gallery_Photo::find($r['album_id']);
+
$a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
}
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
index b9c7558a53..db7c8e9fcd 100644
--- a/apps/gallery/ajax/getCovers.php
+++ b/apps/gallery/ajax/getCovers.php
@@ -18,7 +18,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $
default:
exit();
}
- if(!$myImage) exit();
+ if(!$myImage) exit();
$ratio_orig = $width_orig/$height_orig;
if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
@@ -44,15 +44,19 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $
$box_size = 200;
$album_name= $_GET['album_name'];
-$stmt = OC_DB::prepare('SELECT `file_path` FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.`uid_owner` = ? AND `album_name` = ? AND *PREFIX*gallery_photos.`album_id` = *PREFIX*gallery_albums.`album_id`');
-$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+$result = OC_Gallery_Photo::findForAlbum(OC_User::getUser(), $album_name);
$numOfItems = min($result->numRows(),10);
-$targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+if ($numOfItems){
+ $targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+}
+else{
+ $targetImg = imagecreatetruecolor($box_size, $box_size);
+}
$counter = 0;
while (($i = $result->fetchRow()) && $counter < $numOfItems) {
- $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path'];
+ $imagePath = OC_Filesystem::getLocalFile($i['file_path']);
if(file_exists($imagePath))
{
CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
@@ -65,7 +69,7 @@ header('Content-Type: image/png');
$offset = 3600 * 24;
// calc the string in GMT not localtime and add the offset
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
-header('Cache-Control: max-age=3600, must-revalidate');
+header('Cache-Control: max-age='.$offset.', must-revalidate');
header('Pragma: public');
imagepng($targetImg);
diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php
index bdd591d042..f603cbb497 100644
--- a/apps/gallery/ajax/scanForAlbums.php
+++ b/apps/gallery/ajax/scanForAlbums.php
@@ -3,10 +3,8 @@
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
-require_once('../lib_scanner.php');
-OC_GALLERY_SCANNER::cleanUp();
-OC_JSON::success(array('albums' => OC_GALLERY_SCANNER::scan('')));
-//OC_JSON::success(array('albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa')))));
+OC_Gallery_Scanner::cleanUp();
+OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('')));
?>
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index a141645293..d937691fa0 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -49,12 +49,19 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr
$box_size = 200;
$img = $_GET['img'];
-$tmp = OC::$CONFIG_DATADIRECTORY . $img;
+$imagePath = OC_Filesystem::getLocalFile($img);
-if(file_exists($tmp))
+if(file_exists($imagePath))
{
- header('Content-Type: image/png');
- $image = CroppedThumbnail($tmp, $box_size, $box_size);
+ $image = CroppedThumbnail($imagePath, $box_size, $box_size);
+
+ header('Content-Type: image/png');
+ $offset = 3600 * 24;
+ // calc the string in GMT not localtime and add the offset
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
+ header('Cache-Control: max-age='.$offset.', must-revalidate');
+ header('Pragma: public');
+
imagepng($image);
imagedestroy($image);
-}
\ No newline at end of file
+}
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index 8f855c470e..2b1ab857af 100644
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -1,4 +1,8 @@
20,
'id' => 'gallery',
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css
index 03b179138e..e23d822fec 100644
--- a/apps/gallery/css/styles.css
+++ b/apps/gallery/css/styles.css
@@ -1,13 +1,22 @@
div#gallery_list {
margin: 90pt 20pt;
}
+div#gallery_list.leftcontent {
+ padding-top: 15px;
+ margin: 0;
+ text-align: center;
+}
div#gallery_album_box {
width: 200px;
text-align: center;
border: 0;
- float: left;
+ display: inline-block;
margin: 5pt;
+ vertical-align: top;
+}
+.leftcontent div#gallery_album_box {
+ margin: 5px;
}
div#gallery_album_box h1 {
@@ -21,3 +30,6 @@ div#gallery_album_cover {
border: solid 1px black;
}
+#gallery_images {
+padding:10px 5px;
+}
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
index cb567e3c8f..0cd795bac0 100644
--- a/apps/gallery/index.php
+++ b/apps/gallery/index.php
@@ -13,8 +13,7 @@ if (!file_exists(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'
}
if (!isset($_GET['view'])) {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?');
- $result = $stmt->execute(array(OC_User::getUser()));
+ $result = OC_Gallery_Album::find(OC_User::getUser());
$r = array();
while ($row = $result->fetchRow())
@@ -24,9 +23,7 @@ if (!isset($_GET['view'])) {
$tmpl->assign('r', $r);
$tmpl->printPage();
} else {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id');
-
- $result = $stmt->execute(array(OC_User::getUser(), $_GET['view']));
+ $result = OC_Gallery_Photo::findForAlbum(OC_User::getUser(), $_GET['view']);
$photos = array();
while ($p = $result->fetchRow())
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
index a8e317159d..387cc611d5 100644
--- a/apps/gallery/js/albums.js
+++ b/apps/gallery/js/albums.js
@@ -69,7 +69,7 @@ Albums={
if (albumMetadata == undefined) {
return;
}
- var x = Math.min(Math.floor((e.clientX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
+ var x = Math.min(Math.floor((e.layerX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
x *= this.offsetWidth;
$(this).css('background-position', -x+'px 0');
});
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
new file mode 100644
index 0000000000..6ddfe46de3
--- /dev/null
+++ b/apps/gallery/lib/album.php
@@ -0,0 +1,18 @@
+execute(array($owner, $name));
+ }
+ public static function find($owner, $name=null){
+ $sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
+ $args = array($owner);
+ if (!is_null($name)){
+ $sql .= ' AND album_name = ?';
+ $args[] = $name;
+ }
+ $stmt = OC_DB::prepare($sql);
+ return $stmt->execute($args);
+ }
+}
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
new file mode 100644
index 0000000000..97d159935f
--- /dev/null
+++ b/apps/gallery/lib/photo.php
@@ -0,0 +1,28 @@
+execute(array($albumId, $img));
+ }
+ public static function find($albumId, $img=null){
+ $sql = 'SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?';
+ $args = array($albumId);
+ $args = array($albumId);
+ if (!is_null($img)){
+ $sql .= ' AND file_path = ?';
+ $args[] = $img;
+ }
+ $stmt = OC_DB::prepare($sql);
+ return $stmt->execute($args);
+ }
+ public static function findForAlbum($owner, $album_name){
+ $stmt = OC_DB::prepare('SELECT *'
+ .' FROM *PREFIX*gallery_photos photos,'
+ .' *PREFIX*gallery_albums albums'
+ .' WHERE albums.uid_owner = ?'
+ .' AND albums.album_name = ?'
+ .' AND photos.album_id = albums.album_id');
+ return $stmt->execute(array($owner, $album_name));
+ }
+}
diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib/scanner.php
similarity index 68%
rename from apps/gallery/lib_scanner.php
rename to apps/gallery/lib/scanner.php
index f72d54777a..ef21032796 100644
--- a/apps/gallery/lib_scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -1,9 +1,9 @@
execute(array(OC_User::getUser(), $current_album['name']));
+
+ $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
if ($result->numRows() == 0 && count($current_album['images'])) {
- $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name) VALUES (?, ?)');
- $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ OC_Gallery_Album::create(OC_User::getUser(), $current_album['name']);
+ $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
}
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner LIKE ? AND album_name LIKE ?');
- $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
- $albumId = $result->fetchAll();
- $albumId = $albumId[0]['album_id'];
+ $albumId = $result->fetchRow();
+ $albumId = $albumId['album_id'];
foreach ($current_album['images'] as $img) {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ? AND file_path LIKE ?');
- $result = $stmt->execute(array($albumId, $img));
+ $result = OC_Gallery_Photo::find($albumId, $img);
if ($result->numRows() == 0) {
- $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)');
- $stmt->execute(array($albumId, $img));
+ OC_Gallery_Photo::create($albumId, $img);
}
}
if (count($current_album['images'])) {
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php
index 230e2a5c21..ae43e2fc55 100644
--- a/apps/gallery/templates/view_album.php
+++ b/apps/gallery/templates/view_album.php
@@ -1,5 +1,6 @@
-
+
+
+
+
+
-
+
-
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index 67d5607519..a6738058be 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -31,7 +31,8 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
#collection tr.collapsed td.album, #collection tr.collapsed td.title { color:#ddd; }
-a.expander { float:right; padding:0 1em; }
+td.artist img, td.artist a, td.album img, td.album a { float: left; }
+td.artist a.expander, td.album a.expander { float:right; padding:0 1em; }
tr.active td { background-color:#eee; font-weight:bold; }
tr td { border-top:1px solid #eee; height:2.2em; }
tr .artist img { vertical-align:middle; }
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index 0ad84d6680..bc1f853047 100644
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -128,7 +128,7 @@ class OC_MEDIA_AMPACHE{
$albums=count(OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']));
$songs=count(OC_MEDIA_COLLECTION::getSongs($artist['artist_id']));
$id=$artist['artist_id'];
- $name=utf8_decode(htmlentities($artist['artist_name']));
+ $name=htmlentities($artist['artist_name'], ENT_COMPAT, 'UTF-8');
echo("\t
\n");
echo("\t\t$name \n");
echo("\t\t$albums \n");
@@ -142,10 +142,10 @@ class OC_MEDIA_AMPACHE{
if(!$artistName){
$artistName=OC_MEDIA_COLLECTION::getArtistName($album['album_artist']);
}
- $artistName=utf8_decode(htmlentities($artistName));
+ $artistName=htmlentities($artistName, ENT_COMPAT, 'UTF-8');
$songs=count(OC_MEDIA_COLLECTION::getSongs($album['album_artist'],$album['album_id']));
$id=$album['album_id'];
- $name=utf8_decode(htmlentities($album['album_name']));
+ $name=htmlentities($album['album_name'], ENT_COMPAT, 'UTF-8');
$artist=$album['album_artist'];
echo("\t\n");
echo("\t\t$name \n");
@@ -163,10 +163,10 @@ class OC_MEDIA_AMPACHE{
if(!$albumName){
$albumName=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
}
- $artistName=utf8_decode(htmlentities($artistName));
- $albumName=utf8_decode(htmlentities($albumName));
+ $artistName=htmlentities($artistName, ENT_COMPAT, 'UTF-8');
+ $albumName=htmlentities($albumName, ENT_COMPAT, 'UTF-8');
$id=$song['song_id'];
- $name=utf8_decode(htmlentities($song['song_name']));
+ $name=htmlentities($song['song_name'], ENT_COMPAT, 'UTF-8');
$artist=$song['song_artist'];
$album=$song['song_album'];
echo("\t\n");
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index 571cb7e685..caa3ac3f47 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -267,7 +267,7 @@ class OC_MEDIA_COLLECTION{
$query=self::$queries['addsong'];
}
$query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size));
- $songId=OC_DB::insertid();
+ $songId=OC_DB::insertid('*PREFIX*media_songs');
// self::setLastUpdated();
return self::getSongId($name,$artist,$album);
}
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index ef63cea45d..c2bea2d836 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -93,6 +93,7 @@ class OC_MEDIA_SCANNER{
}
if(!self::$getID3){
self::$getID3=@new getID3();
+ self::$getID3->encoding='UTF-8';
}
$data=@self::$getID3->analyze($file);
getid3_lib::CopyTagsToComments($data);
@@ -105,21 +106,18 @@ class OC_MEDIA_SCANNER{
$artist='unknown';
}else{
$artist=stripslashes($data['comments']['artist'][0]);
- $artist=utf8_encode($artist);
}
if(!isset($data['comments']['album'])){
OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
$album='unknown';
}else{
$album=stripslashes($data['comments']['album'][0]);
- $album=utf8_encode($album);
}
if(!isset($data['comments']['title'])){
OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
$title='unknown';
}else{
$title=stripslashes($data['comments']['title'][0]);
- $title=utf8_encode($title);
}
$size=$data['filesize'];
$track=(isset($data['comments']['track']))?$data['comments']['track'][0]:0;
@@ -150,4 +148,4 @@ class OC_MEDIA_SCANNER{
$ext=substr($filename,strrpos($filename,'.')+1);
return $ext=='mp3' || $ext=='flac' || $ext=='m4a' || $ext=='ogg' || $ext=='oga';
}
-}
\ No newline at end of file
+}
diff --git a/apps/remoteStorage/compat.php b/apps/remoteStorage/WebDAV.php
similarity index 53%
rename from apps/remoteStorage/compat.php
rename to apps/remoteStorage/WebDAV.php
index 445257320c..e048d19e8f 100644
--- a/apps/remoteStorage/compat.php
+++ b/apps/remoteStorage/WebDAV.php
@@ -52,14 +52,11 @@ if(isset($_SERVER['HTTP_ORIGIN'])) {
$path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
$pathParts = explode('/', $path);
// for webdav:
-// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7
-// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key
-// for oauth:
-// 0/ 1 / 2 / 3 / 4
-// /$ownCloudUser/remoteStorage/oauth/auth
+// 0/ 1 / 2 / 3...
+// /$ownCloudUser/remoteStorage/$category/
-if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'webdav') {
- list($dummy0, $ownCloudUser, $dummy2, $dummy3, $userHost, $userName, $dataScope) = $pathParts;
+if(count($pathParts) >= 3 && $pathParts[0] == '') {
+ list($dummy, $ownCloudUser, $dummy2, $category) = $pathParts;
OC_Util::setupFS($ownCloudUser);
@@ -68,10 +65,10 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStor
$server = new Sabre_DAV_Server($publicDir);
// Path to our script
- $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/compat.php/$ownCloudUser");
+ $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/WebDAV.php/$ownCloudUser");
// Auth backend
- $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $userName.'@'.$userHost, $dataScope));
+ $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $category));
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud');//should use $validTokens here
$server->addPlugin($authPlugin);
@@ -83,41 +80,6 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStor
// And off we go!
$server->exec();
-} else if(count($pathParts) >= 4 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'oauth2' && $pathParts[4] = 'auth') {
- if(isset($_POST['allow'])) {
- //TODO: input checking. these explodes may fail to produces the desired arrays:
- $ownCloudUser = $pathParts[1];
- foreach($_GET as $k => $v) {
- if($k=='user_address'){
- $userAddress=$v;
- } else if($k=='redirect_uri'){
- $appUrl=$v;
- } else if($k=='scope'){
- $dataScope=$v;
- }
- }
- if(OC_User::getUser() == $ownCloudUser) {
- //TODO: check if this can be faked by editing the cookie in firebug!
- $token=OC_remoteStorage::createDataScope($appUrl, $userAddress, $dataScope);
- header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=remoteStorage');
- } else {
- if((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'])) {
- $url = "https://";
- } else {
- $url = "http://";
- }
- $url .= $_SERVER['SERVER_NAME'];
- $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php'));
- die('Please '
- .' '
- .', close the pop-up, and '
- .'');
- }
- } else {
- echo '';
- }
} else {
- die('not webdav and not oauth. dont know what to do '.var_export($pathParts, true));
+ die('not the right address format '.var_export($pathParts, true));
}
diff --git a/apps/remoteStorage/appinfo/database.xml b/apps/remoteStorage/appinfo/database.xml
index b4e1ac7d8a..00ee494274 100644
--- a/apps/remoteStorage/appinfo/database.xml
+++ b/apps/remoteStorage/appinfo/database.xml
@@ -29,14 +29,7 @@
64
- dataScope
- text
-
- true
- 64
-
-
- userAddress
+ category
text
true
diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml
index a20c6ff4cd..8179ca9911 100644
--- a/apps/remoteStorage/appinfo/info.xml
+++ b/apps/remoteStorage/appinfo/info.xml
@@ -3,7 +3,7 @@
remoteStorage
remoteStorage compatibility
Enables your users to use ownCloud as their remote storage for unhosted applications.
- 0.1
+ 0.2
AGPL
Michiel de Jong
2
diff --git a/apps/remoteStorage/auth.php b/apps/remoteStorage/auth.php
new file mode 100644
index 0000000000..85421ba3d8
--- /dev/null
+++ b/apps/remoteStorage/auth.php
@@ -0,0 +1,100 @@
+.
+*
+*/
+
+
+// Do not load FS ...
+$RUNTIME_NOSETUPFS = true;
+
+require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('remoteStorage');
+require_once('Sabre/autoload.php');
+require_once('lib_remoteStorage.php');
+require_once('oauth_ro_auth.php');
+
+ini_set('default_charset', 'UTF-8');
+#ini_set('error_reporting', '');
+@ob_clean();
+
+//allow use as remote storage for other websites
+if(isset($_SERVER['HTTP_ORIGIN'])) {
+ header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
+ header('Access-Control-Max-Age: 3600');
+ header('Access-Control-Allow-Methods: OPTIONS, GET, PUT, DELETE, PROPFIND');
+ header('Access-Control-Allow-Headers: Authorization, Content-Type');
+} else {
+ header('Access-Control-Allow-Origin: *');
+}
+
+$path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
+$pathParts = explode('/', $path);
+// for webdav:
+// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7
+// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key
+// for oauth:
+// 0/ 1 / 2 / 3 / 4
+// /$ownCloudUser/remoteStorage/oauth/auth
+
+if(count($pathParts) == 2 && $pathParts[0] == '') {
+ //TODO: input checking. these explodes may fail to produces the desired arrays:
+ $subPathParts = explode('?', $pathParts[1]);
+ $ownCloudUser = $subPathParts[0];
+ foreach($_GET as $k => $v) {
+ if($k=='user_address'){
+ $userAddress=$v;
+ } else if($k=='redirect_uri'){
+ $appUrl=$v;
+ } else if($k=='scope'){
+ $category=$v;
+ }
+ }
+ $currUser = OC_User::getUser();
+ if($currUser == $ownCloudUser) {
+ if(isset($_POST['allow'])) {
+ //TODO: check if this can be faked by editing the cookie in firebug!
+ $token=OC_remoteStorage::createCategory($appUrl, $category);
+ header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=bearer');
+ } else {
+ echo '';
+ }
+ } else {
+ if((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'])) {
+ $url = "https://";
+ } else {
+ $url = "http://";
+ }
+ $url .= $_SERVER['SERVER_NAME'];
+ $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php'));
+ die('You are '.($currUser?'logged in as '.$currUser.' instead of '.$ownCloudUser:'not logged in').'. Please '
+ .' '
+ .', close the pop-up, and '
+ .'');
+ }
+} else {
+ die('please use auth.php/username?params. '.var_export($pathParts, true));
+}
diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php
index f10a72870a..4f19310904 100644
--- a/apps/remoteStorage/lib_remoteStorage.php
+++ b/apps/remoteStorage/lib_remoteStorage.php
@@ -1,38 +1,25 @@
execute(array($ownCloudUser,$userAddress,$dataScope));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'" ';
- $entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
+ public static function getValidTokens($ownCloudUser, $category) {
+ $query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND category=? LIMIT 100");
+ $result=$query->execute(array($ownCloudUser,$category));
$ret = array();
while($row=$result->fetchRow()){
- $ret[$row['token']]=$userAddress;
+ $ret[$row['token']]=true;
}
return $ret;
}
public static function getAllTokens() {
$user=OC_User::getUser();
- $query=OC_DB::prepare("SELECT token,appUrl,userAddress,dataScope FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
+ $query=OC_DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
$result=$query->execute(array($user));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'" ';
- $entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
$ret = array();
while($row=$result->fetchRow()){
$ret[$row['token']] = array(
'appUrl' => $row['appurl'],
- 'userAddress' => $row['useraddress'],
- 'dataScope' => $row['datascope'],
+ 'category' => $row['category'],
);
}
return $ret;
@@ -42,37 +29,24 @@ class OC_remoteStorage {
$user=OC_User::getUser();
$query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?");
$result=$query->execute(array($token,$user));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'" ';
- $entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
}
- private static function addToken($token, $appUrl, $userAddress, $dataScope){
+ private static function addToken($token, $appUrl, $category){
$user=OC_User::getUser();
- $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`userAddress`,`dataScope`) VALUES(?,?,?,?,?)");
- $result=$query->execute(array($token,$appUrl,$user,$userAddress,$dataScope));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'" ';
- $entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
+ $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)");
+ $result=$query->execute(array($token,$appUrl,$user,$category));
}
- public static function createDataScope($appUrl, $userAddress, $dataScope){
+ public static function createCategory($appUrl, $category) {
$token=uniqid();
- self::addToken($token, $appUrl, $userAddress, $dataScope);
- //TODO: input checking on $userAddress and $dataScope
- list($userName, $userHost) = explode('@', $userAddress);
+ self::addToken($token, $appUrl, $category);
+ //TODO: input checking on $category
OC_Util::setupFS(OC_User::getUser());
- $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
+ $scopePathParts = array('remoteStorage', $category);
for($i=0;$i<=count($scopePathParts);$i++){
$thisPath = '/'.implode('/', array_slice($scopePathParts, 0, $i));
if(!OC_Filesystem::file_exists($thisPath)) {
OC_Filesystem::mkdir($thisPath);
}
}
- return $token;
+ return base64_encode('remoteStorage:'.$token);
}
}
diff --git a/apps/remoteStorage/oauth_ro_auth.php b/apps/remoteStorage/oauth_ro_auth.php
index b785d85fea..5403fbe20c 100644
--- a/apps/remoteStorage/oauth_ro_auth.php
+++ b/apps/remoteStorage/oauth_ro_auth.php
@@ -13,6 +13,7 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
+
class OC_Connector_Sabre_Auth_ro_oauth extends Sabre_DAV_Auth_Backend_AbstractBasic {
private $validTokens;
@@ -52,7 +53,7 @@ die('not getting in with "'.$username.'"/"'.$password.'"!');
$auth->setRealm($realm);
$userpass = $auth->getUserPass();
if (!$userpass) {
- if(in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD', 'OPTIONS'))) {
+ if(in_array($_SERVER['REQUEST_METHOD'], array('OPTIONS'))) {
$userpass = array('', '');
} else {
$auth->requireLogin();
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 7906241f79..3261708f59 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -26,7 +26,10 @@ require_once('apps/user_ldap/user_ldap.php');
OC_APP::registerAdmin('user_ldap','settings');
// define LDAP_DEFAULT_PORT
-define("OC_USER_BACKEND_LDAP_DEFAULT_PORT", 389);
+define('OC_USER_BACKEND_LDAP_DEFAULT_PORT', 389);
+
+// define OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME
+define('OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME', 'uid');
// register user backend
OC_User::useBackend( "LDAP" );
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index 8dbd3c0462..1f2d8ed9af 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -20,11 +20,21 @@
* License along with this library. If not, see .
*
*/
-$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter');
+$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase');
-foreach($params as $param){
- if(isset($_POST[$param])){
- OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
+if ($_POST) {
+ foreach($params as $param){
+ if(isset($_POST[$param])){
+ OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
+ }
+ elseif('ldap_tls' == $param) {
+ // unchecked checkboxes are not included in the post paramters
+ OC_Appconfig::setValue('user_ldap', $param, 0);
+ }
+ elseif('ldap_nocase' == $param) {
+ OC_Appconfig::setValue('user_ldap', $param, 0);
+ }
+
}
}
@@ -38,4 +48,7 @@ foreach($params as $param){
// ldap_port has a default value
$tmpl->assign( 'ldap_port', OC_Appconfig::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
+// ldap_display_name has a default value
+$tmpl->assign( 'ldap_display_name', OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME));
+
return $tmpl->fetchPage();
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 32e1b29daf..2abb0b4729 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -1,12 +1,17 @@
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 1154efc17b..106240e74b 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -33,6 +33,9 @@ class OC_USER_LDAP extends OC_User_Backend {
protected $ldap_password;
protected $ldap_base;
protected $ldap_filter;
+ protected $ldap_tls;
+ protected $ldap_nocase;
+ protected $ldap_display_name;
function __construct() {
$this->ldap_host = OC_Appconfig::getValue('user_ldap', 'ldap_host','');
@@ -41,13 +44,16 @@ class OC_USER_LDAP extends OC_User_Backend {
$this->ldap_password = OC_Appconfig::getValue('user_ldap', 'ldap_password','');
$this->ldap_base = OC_Appconfig::getValue('user_ldap', 'ldap_base','');
$this->ldap_filter = OC_Appconfig::getValue('user_ldap', 'ldap_filter','');
+ $this->ldap_tls = OC_Appconfig::getValue('user_ldap', 'ldap_tls', 0);
+ $this->ldap_nocase = OC_Appconfig::getValue('user_ldap', 'ldap_nocase', 0);
+ $this->ldap_display_name = OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME);
if( !empty($this->ldap_host)
&& !empty($this->ldap_port)
- && !empty($this->ldap_dn)
- && !empty($this->ldap_password)
+ && ((!empty($this->ldap_dn) && !empty($this->ldap_password)) || (empty($this->ldap_dn) && empty($this->ldap_password)))
&& !empty($this->ldap_base)
&& !empty($this->ldap_filter)
+ && !empty($this->ldap_display_name)
)
{
$this->configured = true;
@@ -63,9 +69,10 @@ class OC_USER_LDAP extends OC_User_Backend {
private function getDs() {
if(!$this->ds) {
$this->ds = ldap_connect( $this->ldap_host, $this->ldap_port );
- if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
- if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0))
- ldap_start_tls($this->ds);
+ if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
+ if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0))
+ if($this->ldap_tls)
+ ldap_start_tls($this->ds);
}
// login
@@ -88,15 +95,16 @@ class OC_USER_LDAP extends OC_User_Backend {
return false;
// get dn
- $filter = str_replace("%uid", $uid, $this->ldap_filter);
+ $filter = str_replace('%uid', $uid, $this->ldap_filter);
$sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
$entries = ldap_get_entries( $this->getDs(), $sr );
- if( $entries["count"] == 0 )
+ if( $entries['count'] == 0 )
return false;
- return $entries[0]["dn"];
+ return $entries[0]['dn'];
}
+
public function checkPassword( $uid, $password ) {
if(!$this->configured){
return false;
@@ -107,7 +115,28 @@ class OC_USER_LDAP extends OC_User_Backend {
if (!@ldap_bind( $this->getDs(), $dn, $password ))
return false;
- return $uid;
+
+ if($this->ldap_nocase) {
+ $filter = str_replace('%uid', $uid, $this->ldap_filter);
+ $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
+ $entries = ldap_get_entries( $this->getDs(), $sr );
+ if( $entries['count'] == 1 ) {
+ foreach($entries as $row) {
+ $ldap_display_name = strtolower($this->ldap_display_name);
+ if(isset($row[$ldap_display_name])) {
+ return $row[$ldap_display_name][0];
+ }
+ }
+ }
+ else {
+ return $uid;
+ }
+
+ }
+ else {
+ return $uid;
+ }
+
}
public function userExists( $uid ) {
@@ -117,6 +146,37 @@ class OC_USER_LDAP extends OC_User_Backend {
$dn = $this->getDn($uid);
return !empty($dn);
}
+
+ public function getUsers()
+ {
+ if(!$this->configured)
+ return false;
+
+ // connect to server
+ $ds = $this->getDs();
+ if( !$ds )
+ return false;
+
+ // get users
+ $filter = 'objectClass=person';
+ $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
+ $entries = ldap_get_entries( $this->getDs(), $sr );
+ if( $entries['count'] == 0 )
+ return false;
+ else {
+ $users = array();
+ foreach($entries as $row) {
+ // TODO ldap_get_entries() seems to lower all keys => needs review
+ $ldap_display_name = strtolower($this->ldap_display_name);
+ if(isset($row[$ldap_display_name])) {
+ $users[] = $row[$ldap_display_name][0];
+ }
+ }
+ // TODO language specific sorting of user names
+ sort($users);
+ return $users;
+ }
+ }
}
diff --git a/apps/user_webfinger/webfinger.php b/apps/user_webfinger/webfinger.php
index afb5368968..d695a833f3 100644
--- a/apps/user_webfinger/webfinger.php
+++ b/apps/user_webfinger/webfinger.php
@@ -4,7 +4,14 @@ if($_SERVER['SCRIPT_NAME'] == '/.well-known/webfinger.php') {
} else {
header('Please-first: activate');
}
-header("Content-Type: application/xml+xrd");
+// header("Content-Type: application/xml+xrd");
+
+// calculate the documentroot
+// modified version of the one in lib/base.php that takes the .well-known symlink into account
+$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
+$SERVERROOT=str_replace("\\",'/',dirname(dirname(dirname(dirname(__FILE__)))));
+$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
+$WEBROOT=substr($SUBURI,0,-34);
if($_GET['q']) {
$bits = explode('@', $_GET['q']);
@@ -15,10 +22,20 @@ if($_GET['q']) {
if(substr($userName, 0, 5) == 'acct:') {
$userName = substr($userName, 5);
}
+if($_SERVER['HTTPS']) {
+ $baseAddress = 'https://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
+} else {
+ $baseAddress = 'http://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
+}
echo "<";
?>
?xml version="1.0" encoding="UTF-8"?>
-
+
diff --git a/core/css/styles.css b/core/css/styles.css
index 0f591859f3..d1c648383c 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -32,14 +32,14 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', end
/* INPUTS */
input[type="text"], input[type="password"] { cursor:text; }
-input, select, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; }
+input, select, button, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; }
input[type="text"], input[type="password"], input[type="search"] { background:#f8f8f8; color:#555; cursor:text; }
input[type="text"], input[type="password"], input[type="search"] { -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; }
input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,
input[type="password"]:hover, input[type="password"]:focus, input[type="password"]:active,
.searchbox input[type="search"]:hover, .searchbox input[type="search"]:focus, .searchbox input[type="search"]:active { background-color:#fff; color:#333; opacity:1; }
-input[type="submit"], input[type="button"], .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
+input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="checkbox"] { width:auto; }
#quota { cursor:default; }
diff --git a/core/img/actions/upload.png b/core/img/actions/upload.png
new file mode 100644
index 0000000000..5744aad75a
Binary files /dev/null and b/core/img/actions/upload.png differ
diff --git a/core/img/actions/upload.svg b/core/img/actions/upload.svg
new file mode 100644
index 0000000000..91333bb681
--- /dev/null
+++ b/core/img/actions/upload.svg
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+ image/svg+xml
+
+
+
+
+
+
+
+
+
diff --git a/core/js/jquery-tipsy.js b/core/js/jquery-tipsy.js
index 9567ed3bac..ef4bbfd87a 100644
--- a/core/js/jquery-tipsy.js
+++ b/core/js/jquery-tipsy.js
@@ -31,6 +31,10 @@
height: this.$element[0].offsetHeight
});
+ if (this.options.className) {
+ $tip.addClass(maybeCall(this.options.className, this.$element[0]));
+ }
+
var actualWidth = $tip[0].offsetWidth,
actualHeight = $tip[0].offsetHeight,
gravity = maybeCall(this.options.gravity, this.$element[0]);
@@ -61,9 +65,6 @@
$tip.css(tp).addClass('tipsy-' + gravity);
$tip.find('.tipsy-arrow')[0].className = 'tipsy-arrow tipsy-arrow-' + gravity.charAt(0);
- if (this.options.className) {
- $tip.addClass(maybeCall(this.options.className, this.$element[0]));
- }
if (this.options.fade) {
$tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
diff --git a/core/js/js.js b/core/js/js.js
index 9e814ca072..5846d28988 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -365,7 +365,7 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
- $('.file_upload_button_wrapper').tipsy({gravity:'e', fade:true});
+ $('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
$('.selectedActions a.delete').tipsy({gravity: 'se', fade:true, live:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('#headerSize').tipsy({gravity:'s', fade:true, live:true});
@@ -401,3 +401,10 @@ if (!Array.prototype.map){
return res;
};
}
+
+/**
+ * Filter Jquery selector by attribute value
+ **/
+$.fn.filterAttr = function(attr_name, attr_value) {
+ return this.filter(function() { return $(this).attr(attr_name) === attr_value; });
+};
diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php
index de0d393ec7..ede94dab2d 100644
--- a/core/lostpassword/index.php
+++ b/core/lostpassword/index.php
@@ -14,7 +14,7 @@ if (isset($_POST['user'])) {
if (OC_User::userExists($_POST['user'])) {
$token = sha1($_POST['user']+uniqId());
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
- $email = OC_Preferences::getValue($_POST['user'], 'lostpassword', 'email', '');
+ $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {
$link = OC_Helper::linkTo('core/lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token;
$tmpl = new OC_Template('core/lostpassword', 'email');
diff --git a/files/ajax/newfile.php b/files/ajax/newfile.php
new file mode 100644
index 0000000000..5c4f49a367
--- /dev/null
+++ b/files/ajax/newfile.php
@@ -0,0 +1,27 @@
+ array( "message" => "Empty Filename" )));
+ exit();
+}
+
+if(OC_Files::newFile($dir, $filename, 'file')) {
+ if($content){
+ OC_Filesystem::file_put_contents($dir.'/'.$filename,$content);
+ }
+ OC_JSON::success(array("data" => array('content'=>$content)));
+ exit();
+}
+
+
+OC_JSON::error(array("data" => array( "message" => "Error when creating the file" )));
\ No newline at end of file
diff --git a/files/css/files.css b/files/css/files.css
index ac1f523f86..22f4810d0a 100644
--- a/files/css/files.css
+++ b/files/css/files.css
@@ -3,15 +3,22 @@
See the COPYING-README file. */
/* FILE MENU */
-.actions { padding:.3em; float:left; }
-.actions input { margin:0; }
+.actions { padding:.3em; float:left; height:2em; }
+.actions input, .actions button, .actions .button { margin:0; }
#file_menu { right:0; position:absolute; top:0; }
#file_menu a { display:block; float:left; background-image:none; text-decoration:none; }
-.file_upload_form, #file_newfolder_form { display:inline; float: left; margin-left:.5em; }
+.file_upload_form, #file_newfolder_form { display:inline; float: left; margin-left:0; }
#fileSelector, #file_upload_submit, #file_newfolder_submit { display:none; }
.file_upload_wrapper, #file_newfolder_name { background-repeat:no-repeat; background-position:.5em .5em; padding-left:2em; }
-.file_upload_wrapper { font-weight:bold; display:-moz-inline-box; /* fallback for older firefox versions*/ display:inline-block; padding-left:0; overflow:hidden; position:relative; margin:.1em .1em .1em 0em;}
+.file_upload_wrapper { font-weight:bold; display:-moz-inline-box; /* fallback for older firefox versions*/ display:inline-block; padding-left:0; overflow:hidden; position:relative; margin:0;}
.file_upload_wrapper .file_upload_button_wrapper { position:absolute; top:0; left:0; width:100%; height:100%; cursor:pointer; z-index:1000; }
+#new { float:left; border-top-right-radius:0; border-bottom-right-radius:0; margin:0 0 0 1em; border-right:none; z-index:1010; height:1.3em; }
+#new.active { border-bottom-left-radius:0; border-bottom:none; background:#f8f8f8 }
+#new>a{ padding-left:1em; padding-right:1em; }
+#new>ul { display:none; position:fixed; text-align:left; padding:.5em; background:#f8f8f8; margin-top:0.075em; border:1px solid #ddd; min-width:7em; margin-left:-.5em; z-index:-1; }
+#new>ul>li { margin:.3em; padding-left:2em; background-repeat:no-repeat; cursor:pointer; padding-bottom:0.1em }
+#new>ul>li>p { cursor:pointer; }
+#new>ul>li>input { padding:0.3em; margin:-0.3em; }
#file_newfolder_name { background-image:url('../../core/img/places/folder.svg'); font-weight:normal; width:7em; }
.file_upload_start, .file_upload_filename { font-size:1em; }
@@ -19,7 +26,9 @@
.file_upload_target { display:none; }
.file_upload_start { opacity:0; filter:alpha(opacity=0); z-index:1; position:absolute; left:0; top:0; width:100%; cursor:pointer;}
-.file_upload_filename { z-index:100; cursor:pointer;}
+.file_upload_filename.active { border-bottom-right-radius:0 }
+.file_upload_filename { z-index:100; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; padding:.3em; }
+
.file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; }
diff --git a/files/index.php b/files/index.php
index 8bb5b618d8..7e156130d8 100644
--- a/files/index.php
+++ b/files/index.php
@@ -89,10 +89,15 @@ $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+$freeSpace=OC_Filesystem::free_space('/');
+$freeSpace=max($freeSpace,0);
+$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
+
$tmpl = new OC_Template( "files", "index", "user" );
$tmpl->assign( "fileList", $list->fetchPage() );
$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
$tmpl->assign( 'dir', $dir);
+$tmpl->assign( 'readonly', !OC_Filesystem::is_writeable($dir));
$tmpl->assign( "files", $files );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index f95c5e84dc..9e2688e82c 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -56,7 +56,7 @@ FileActions={
$('#fileList .action').remove();
var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
var file=FileActions.getCurrentFile();
- if($('tr[data-file="'+file+'"]').data('renaming')){
+ if($('tr').filterAttr('data-file',file).data('renaming')){
return;
}
var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
diff --git a/files/js/filelist.js b/files/js/filelist.js
index 863a3385d1..16f73ed58d 100644
--- a/files/js/filelist.js
+++ b/files/js/filelist.js
@@ -4,7 +4,7 @@ FileList={
},
addFile:function(name,size,lastModified,loading){
var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png');
- var html='';
+ var html=' ';
if(name.indexOf('.')!=-1){
var basename=name.substr(0,name.lastIndexOf('.'));
var extention=name.substr(name.lastIndexOf('.'));
@@ -29,16 +29,21 @@ FileList={
html+=''+simpleSize+' ';
html+=''+relative_modified_date(lastModified.getTime() / 1000)+' ';
html+=' ';
- FileList.insertElement(name,'file',$(html));
+ FileList.insertElement(name,'file',$(html).attr('data-file',name));
if(loading){
- $('tr[data-file="'+name+'"]').data('loading',true);
+ $('tr').filterAttr('data-file',name).data('loading',true);
}else{
- $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions);
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
}
},
addDir:function(name,size,lastModified){
- var html='';
- html+=''+name+' ';
+ html = $(' ').attr({ "data-type": "dir", "data-size": size, "data-file": name});
+ td = $(' ').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' });
+ td.append(' ');
+ var link_elem = $(' ').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name) });
+ link_elem.append($(' ').addClass('nametext').text(name));
+ td.append(link_elem);
+ html.append(td);
if(size!='Pending'){
simpleSize=simpleFileSize(size);
}else{
@@ -47,13 +52,15 @@ FileList={
sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
lastModifiedTime=Math.round(lastModified.getTime() / 1000);
modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
- html+=''+simpleSize+' ';
- html+=''+relative_modified_date(lastModified.getTime() / 1000)+' ';
- html+='';
+ td = $(' ').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize);
+ html.append(td);
- FileList.insertElement(name,'dir',$(html));
- $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions);
- $('tr[data-file="'+name+'"] td.filename').droppable(folderDropOptions);
+ td = $(' ').attr({ "class": "date" });
+ td.append($(' ').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) ));
+ html.append(td);
+ FileList.insertElement(name,'dir',html);
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
+ $('tr').filterAttr('data-file',name).find('td.filename').droppable(folderDropOptions);
},
refresh:function(data) {
result = jQuery.parseJSON(data.responseText);
@@ -64,8 +71,8 @@ FileList={
resetFileActionPanel();
},
remove:function(name){
- $('tr[data-file="'+name+'"] td.filename').draggable('destroy');
- $('tr[data-file="'+name+'"]').remove();
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
+ $('tr').filterAttr('data-file',name).remove();
if($('tr[data-file]').length==0){
$('#emptyfolder').show();
$('.file_upload_filename').addClass('highlight');
@@ -101,7 +108,7 @@ FileList={
$('.file_upload_filename').removeClass('highlight');
},
loadingDone:function(name){
- var tr=$('tr[data-file="'+name+'"]');
+ var tr=$('tr').filterAttr('data-file',name);
tr.data('loading',false);
var mime=tr.data('mime');
tr.attr('data-mime',mime);
@@ -111,14 +118,14 @@ FileList={
tr.find('td.filename').draggable(dragOptions);
},
isLoading:function(name){
- return $('tr[data-file="'+name+'"]').data('loading');
+ return $('tr').filterAttr('data-file',name).data('loading');
},
rename:function(name){
- var tr=$('tr[data-file="'+name+'"]');
+ var tr=$('tr').filterAttr('data-file',name);
tr.data('renaming',true);
var td=tr.children('td.filename');
- var input=$(' ');
- var form=$('')
+ var input=$(' ').val(name);
+ var form=$('')
form.append(input);
td.children('a.name').text('');
td.children('a.name').append(form)
@@ -127,7 +134,6 @@ FileList={
event.stopPropagation();
event.preventDefault();
var newname=input.val();
- tr.data('renaming',false);
tr.attr('data-file',newname);
td.children('a.name').empty();
if(newname.indexOf('.')>0){
@@ -141,12 +147,12 @@ FileList={
if(newname.indexOf('.')>0){
span.append($(''+newname.substr(newname.lastIndexOf('.'))+' '));
}
- $.ajax({
- url: 'ajax/rename.php',
- data: "dir="+$('#dir').val()+"&newname="+encodeURIComponent(newname)+"&file="+encodeURIComponent(name)
+ $.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(){
+ tr.data('renaming',false);
});
+ return false;
});
- form.click(function(event){
+ input.click(function(event){
event.stopPropagation();
event.preventDefault();
});
@@ -165,9 +171,10 @@ FileList={
files=[files];
}
$.each(files,function(index,file){
- $('tr[data-file="'+file+'"]').hide();
- $('tr[data-file="'+file+'"]').find('input[type="checkbox"]').removeAttr('checked');
- $('tr[data-file="'+file+'"]').removeClass('selected');
+ var files = $('tr').filterAttr('data-file',file);
+ files.hide();
+ files.find('input[type="checkbox"]').removeAttr('checked');
+ files.removeClass('selected');
});
procesSelection();
FileList.deleteCanceled=false;
@@ -208,7 +215,7 @@ $(document).ready(function(){
if($('#notification').data('deletefile'))
{
$.each(FileList.deleteFiles,function(index,file){
- $('tr[data-file="'+file+'"]').show();
+ $('tr').filterAttr('data-file',file).show();
// alert(file);
});
FileList.deleteCanceled=true;
diff --git a/files/js/files.js b/files/js/files.js
index 902c5e5493..5a528f5122 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -1,4 +1,9 @@
$(document).ready(function() {
+ $('#fileList tr').each(function(){
+ //little hack to set unescape filenames in attribute
+ $(this).attr('data-file',decodeURIComponent($(this).attr('data-file')));
+ });
+
if($('tr[data-file]').length==0){
$('.file_upload_filename').addClass('highlight');
}
@@ -9,8 +14,8 @@ $(document).ready(function() {
$('#fileList tr td.filename').draggable(dragOptions);
$('#fileList tr[data-type="dir"] td.filename').droppable(folderDropOptions);
$('div.crumb').droppable(crumbDropOptions);
- $('#plugins>ul>li:first-child').data('dir','');
- $('#plugins>ul>li:first-child').droppable(crumbDropOptions);
+ $('ul#apps>li:first-child').data('dir','');
+ $('ul#apps>li:first-child').droppable(crumbDropOptions);
// Triggers invisible file input
$('.file_upload_button_wrapper').live('click', function() {
@@ -64,8 +69,10 @@ $(document).ready(function() {
}
procesSelection();
} else {
- var filename=$(this).parent().parent().data('file');
- if(!FileList.isLoading(filename)){
+ var filename=$(this).parent().parent().attr('data-file');
+ var tr=$('tr').filterAttr('data-file',filename);
+ var renaming=tr.data('renaming')
+ if(!renaming && !FileList.isLoading(filename)){
var mime=$(this).parent().parent().data('mime');
var type=$(this).parent().parent().data('type');
var action=FileActions.getDefault(mime,type);
@@ -158,7 +165,7 @@ $(document).ready(function() {
});
$('.file_upload_start').live('change',function(){
- var form=$(this).parent().parent();
+ var form=$(this).closest('form');
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
@@ -185,9 +192,9 @@ $(document).ready(function() {
if(response[0] != undefined && response[0].status == 'success'){
for(var i=0;iul').hide();
+ $('#new').removeClass('active');
+ $('button.file_upload_filename').removeClass('active');
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
+ $(element).children('input').remove();
+ $(element).append(''+$(element).data('text')+'
');
+ }
+ });
+ });
+ $('#new').click(function(event){
+ event.stopPropagation();
+ });
+ $('#new>a').click(function(){
+ $('#new>ul').toggle();
+ $('#new').toggleClass('active');
+ $('button.file_upload_filename').toggleClass('active');
+ });
+ $('#new li').click(function(){
+ if($(this).children('p').length==0){
+ return;
+ }
+
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
+ $(element).children('input').remove();
+ $(element).append(''+$(element).data('text')+'
');
+ }
+ });
+
+ var type=$(this).data('type');
+ var text=$(this).children('p').text();
+ $(this).data('text',text);
+ $(this).children('p').remove();
+ var input=$(' ');
+ $(this).append(input);
+ input.focus();
+ input.change(function(){
+ var name=$(this).val();
+ switch(type){
+ case 'file':
+ $.ajax({
+ url: OC.filePath('files','ajax','newfile.php'),
+ data: "dir="+encodeURIComponent($('#dir').val())+"&filename="+encodeURIComponent(name)+'&content=%20%0A',
+ complete: function(data){boolOperationFinished(data, function(){
+ var date=new Date();
+ FileList.addFile(name,0,date);
+ var tr=$('tr').filterAttr('data-file',name);
+ tr.data('mime','text/plain');
+ getMimeIcon('text/plain',function(path){
+ tr.find('td.filename').attr('style','background-image:url('+path+')');
+ });
+ });}
+ });
+ break;
+ case 'folder':
+ $.ajax({
+ url: OC.filePath('files','ajax','newfolder.php'),
+ data: "dir="+encodeURIComponent($('#dir').val())+"&foldername="+encodeURIComponent(name),
+ complete: function(data){boolOperationFinished(data, function(){
+ var date=new Date();
+ FileList.addDir(name,0,date);
+ });}
+ });
+ break;
+ }
+ var li=$(this).parent();
+ $(this).remove();
+ li.append(''+li.data('text')+'
');
+ $('#new>a').click();
+ });
+ });
});
-var adjustNewFolderSize = function() {
- if($('#file_newfolder_name').val() != '') {
- splitSize($('#file_newfolder_name'),$('#file_newfolder_submit'));
- $('#file_newfolder_name').unbind('keyup', adjustNewFolderSize);
- };
-}
-
-function splitSize(existingEl, appearingEl) {
- nw = parseInt($(existingEl).css('width')) - parseInt($(appearingEl).css('width'));
- $(existingEl).css('width', nw + 'px');
- $(appearingEl).fadeIn(250);
-}
-
-function unsplitSize(stayingEl, vanishingEl) {
- nw = parseInt($(stayingEl).css('width')) + parseInt($(vanishingEl).css('width'));
- $(stayingEl).css('width', nw + 'px');
- $(vanishingEl).fadeOut(250);
-}
-
-function resetFileActionPanel() {
- $('#file_action_panel form').css({"display":"none"});
- $('#file_action_panel').attr('activeAction', false);
-}
-
function boolOperationFinished(data, callback) {
result = jQuery.parseJSON(data.responseText);
if(result.status == 'success'){
@@ -343,7 +400,7 @@ var folderDropOptions={
url: 'ajax/move.php',
data: "dir="+dir+"&file="+file+'&target='+dir+'/'+target,
complete: function(data){boolOperationFinished(data, function(){
- var el=$('#fileList tr[data-file="'+file+'"] td.filename');
+ var el = $('#fileList tr').filterAttr('data-file',file).find('td.filename');
el.draggable('destroy');
FileList.remove(file);
});}
@@ -445,7 +502,7 @@ function getSelectedFiles(property){
var files=[];
elements.each(function(i,element){
var file={
- name:$(element).data('file'),
+ name:$(element).attr('data-file'),
mime:$(element).data('mime'),
type:$(element).data('type'),
size:$(element).data('size'),
diff --git a/files/templates/index.php b/files/templates/index.php
index a63f6e62b6..c4acab25cc 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -1,35 +1,37 @@
-
-
-
-
-
t('Nothing in here. Upload something!')?>
-
+
+
t('Nothing in here. Upload something!')?>
+
@@ -46,7 +48,7 @@ if (isset($_['files'])) {
-
+
diff --git a/files/templates/part.list.php b/files/templates/part.list.php
index 6bf5efe2fb..46830ba3a3 100644
--- a/files/templates/part.list.php
+++ b/files/templates/part.list.php
@@ -5,7 +5,7 @@
$relative_modified_date = relative_modified_date($file['mtime']);
$relative_date_color = round((time()-$file['mtime'])/60/60/24*14); // the older the file, the brighter the shade of grey; days*14
if($relative_date_color>200) $relative_date_color = 200; ?>
-
'>
+ '>
diff --git a/index.php b/index.php
index 558733e1cd..2d759d68d7 100644
--- a/index.php
+++ b/index.php
@@ -88,7 +88,7 @@ else {
if(defined("DEBUG") && DEBUG) {
OC_Log::write('core','Setting remember login to cookie',OC_Log::DEBUG);
}
- $token = md5($_POST["user"].time());
+ $token = md5($_POST["user"].time().$_POST['password']);
OC_Preferences::setValue($_POST['user'], 'login', 'token', $token);
OC_User::setMagicInCookie($_POST["user"], $token);
}
diff --git a/l10n/templates/calendar.pot b/l10n/templates/calendar.pot
index 66cc90a4bf..56fce2285e 100644
--- a/l10n/templates/calendar.pot
+++ b/l10n/templates/calendar.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-09-24 23:05+0200\n"
+"POT-Creation-Date: 2011-10-22 13:05+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -17,318 +17,180 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ajax/createcalendar.php:18 ajax/settimezone.php:19
-#: ajax/updatecalendar.php:18
-msgid "Authentication error"
-msgstr ""
-
-#: ajax/editeventform.php:25
+#: ajax/editeventform.php:26
msgid "Wrong calendar"
msgstr ""
-#: ajax/settimezone.php:27
+#: ajax/settimezone.php:22
msgid "Timezone changed"
msgstr ""
-#: ajax/settimezone.php:29
+#: ajax/settimezone.php:24
msgid "Invalid request"
msgstr ""
-#: appinfo/app.php:19 templates/part.eventform.php:27
-#: templates/part.eventinfo.php:18
+#: appinfo/app.php:21 templates/calendar.php:11
+#: templates/part.eventform.php:21
msgid "Calendar"
msgstr ""
-#: lib/object.php:292
+#: js/calendar.js:153
+msgid "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}"
+msgstr ""
+
+#: js/calendar.js:155
+msgid "ddd d MMMM[ yyyy] HH:mm{ -[ ddd d MMMM yyyy] HH:mm}"
+msgstr ""
+
+#: lib/object.php:344
msgid "Birthday"
msgstr ""
-#: lib/object.php:293
+#: lib/object.php:345
msgid "Business"
msgstr ""
-#: lib/object.php:294
+#: lib/object.php:346
msgid "Call"
msgstr ""
-#: lib/object.php:295
+#: lib/object.php:347
msgid "Clients"
msgstr ""
-#: lib/object.php:296
+#: lib/object.php:348
msgid "Deliverer"
msgstr ""
-#: lib/object.php:297
+#: lib/object.php:349
msgid "Holidays"
msgstr ""
-#: lib/object.php:298
+#: lib/object.php:350
msgid "Ideas"
msgstr ""
-#: lib/object.php:299
+#: lib/object.php:351
msgid "Journey"
msgstr ""
-#: lib/object.php:300
+#: lib/object.php:352
msgid "Jubilee"
msgstr ""
-#: lib/object.php:301
+#: lib/object.php:353
msgid "Meeting"
msgstr ""
-#: lib/object.php:302
+#: lib/object.php:354
msgid "Other"
msgstr ""
-#: lib/object.php:303
+#: lib/object.php:355
msgid "Personal"
msgstr ""
-#: lib/object.php:304
+#: lib/object.php:356
msgid "Projects"
msgstr ""
-#: lib/object.php:305
+#: lib/object.php:357
msgid "Questions"
msgstr ""
-#: lib/object.php:306
+#: lib/object.php:358
msgid "Work"
msgstr ""
-#: lib/object.php:313
+#: lib/object.php:365
msgid "Does not repeat"
msgstr ""
-#: lib/object.php:314
+#: lib/object.php:366
msgid "Daily"
msgstr ""
-#: lib/object.php:315
+#: lib/object.php:367
msgid "Weekly"
msgstr ""
-#: lib/object.php:316
+#: lib/object.php:368
msgid "Every Weekday"
msgstr ""
-#: lib/object.php:317
+#: lib/object.php:369
msgid "Bi-Weekly"
msgstr ""
-#: lib/object.php:318
+#: lib/object.php:370
msgid "Monthly"
msgstr ""
-#: lib/object.php:319
+#: lib/object.php:371
msgid "Yearly"
msgstr ""
-#: lib/object.php:337
+#: lib/object.php:389
msgid "Not an array"
msgstr ""
-#: templates/calendar.php:3
+#: templates/calendar.php:8
msgid "All day"
msgstr ""
-#: templates/calendar.php:32
-msgid "Sunday"
+#: templates/calendar.php:9
+msgid "Missing fields"
msgstr ""
-#: templates/calendar.php:32
-msgid "Monday"
+#: templates/calendar.php:10 templates/part.eventform.php:3
+msgid "Title"
msgstr ""
-#: templates/calendar.php:32
-msgid "Tuesday"
+#: templates/calendar.php:12
+msgid "From Date"
msgstr ""
-#: templates/calendar.php:32
-msgid "Wednesday"
+#: templates/calendar.php:13
+msgid "From Time"
msgstr ""
-#: templates/calendar.php:32
-msgid "Thursday"
+#: templates/calendar.php:14
+msgid "To Date"
msgstr ""
-#: templates/calendar.php:32
-msgid "Friday"
+#: templates/calendar.php:15
+msgid "To Time"
msgstr ""
-#: templates/calendar.php:32
-msgid "Saturday"
+#: templates/calendar.php:16
+msgid "The event ends before it starts"
msgstr ""
-#: templates/calendar.php:33
-msgid "Sun."
+#: templates/calendar.php:17
+msgid "There was a database fail"
msgstr ""
-#: templates/calendar.php:33
-msgid "Mon."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Tue."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Wed."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Thu."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Fri."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Sat."
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "January"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "February"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "March"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "April"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "May"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "June"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "July"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "August"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "September"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "October"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "November"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "December"
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Jan."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Feb."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Mar."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Apr."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "May."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Jun."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Jul."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Aug."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Sep."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Oct."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Nov."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Dec."
-msgstr ""
-
-#: templates/calendar.php:36 templates/calendar.php:50
-#: templates/calendar.php:116
+#: templates/calendar.php:23
msgid "Week"
msgstr ""
-#: templates/calendar.php:37 templates/calendar.php:51
-msgid "Weeks"
-msgstr ""
-
-#: templates/calendar.php:38
-msgid "More before {startdate}"
-msgstr ""
-
-#: templates/calendar.php:39
-msgid "More after {enddate}"
-msgstr ""
-
-#: templates/calendar.php:49
-msgid "Day"
-msgstr ""
-
-#: templates/calendar.php:52
+#: templates/calendar.php:24
msgid "Month"
msgstr ""
-#: templates/calendar.php:53
+#: templates/calendar.php:25
msgid "List"
msgstr ""
-#: templates/calendar.php:58
+#: templates/calendar.php:30
msgid "Today"
msgstr ""
-#: templates/calendar.php:59
+#: templates/calendar.php:31
msgid "Calendars"
msgstr ""
-#: templates/calendar.php:76 templates/calendar.php:94
-msgid "Time"
-msgstr ""
-
-#: templates/calendar.php:169
+#: templates/calendar.php:48
msgid "There was a fail, while parsing the file."
msgstr ""
@@ -350,7 +212,6 @@ msgid "Download"
msgstr ""
#: templates/part.choosecalendar.rowfields.php:4
-#: templates/part.eventinfo.php:64
msgid "Edit"
msgstr ""
@@ -367,7 +228,7 @@ msgstr ""
msgid "Edit calendar"
msgstr ""
-#: templates/part.editcalendar.php:12
+#: templates/part.editcalendar.php:12 templates/part.import.php:29
msgid "Displayname"
msgstr ""
@@ -375,88 +236,135 @@ msgstr ""
msgid "Active"
msgstr ""
-#: templates/part.editcalendar.php:29 templates/part.eventform.php:88
-#: templates/part.eventinfo.php:58
-msgid "Description"
-msgstr ""
-
-#: templates/part.editcalendar.php:35
+#: templates/part.editcalendar.php:29
msgid "Calendar color"
msgstr ""
-#: templates/part.editcalendar.php:41
+#: templates/part.editcalendar.php:42
msgid "Save"
msgstr ""
-#: templates/part.editcalendar.php:41 templates/part.editevent.php:7
+#: templates/part.editcalendar.php:42 templates/part.editevent.php:7
#: templates/part.newevent.php:6
msgid "Submit"
msgstr ""
-#: templates/part.editcalendar.php:42
+#: templates/part.editcalendar.php:43
msgid "Cancel"
msgstr ""
-#: templates/part.editevent.php:1 templates/part.eventinfo.php:1
+#: templates/part.editevent.php:1
msgid "Edit an event"
msgstr ""
-#: templates/part.eventform.php:3 templates/part.eventinfo.php:4
-msgid "Title"
+#: templates/part.editevent.php:9
+msgid "Export"
msgstr ""
#: templates/part.eventform.php:5
msgid "Title of the Event"
msgstr ""
-#: templates/part.eventform.php:9 templates/part.eventinfo.php:9
-msgid "Location"
-msgstr ""
-
#: templates/part.eventform.php:11
-msgid "Location of the Event"
-msgstr ""
-
-#: templates/part.eventform.php:17 templates/part.eventinfo.php:16
msgid "Category"
msgstr ""
-#: templates/part.eventform.php:19
+#: templates/part.eventform.php:13
msgid "Select category"
msgstr ""
-#: templates/part.eventform.php:45 templates/part.eventinfo.php:28
+#: templates/part.eventform.php:39
msgid "All Day Event"
msgstr ""
-#: templates/part.eventform.php:49 templates/part.eventinfo.php:31
+#: templates/part.eventform.php:43
msgid "From"
msgstr ""
-#: templates/part.eventform.php:57 templates/part.eventinfo.php:38
+#: templates/part.eventform.php:51
msgid "To"
msgstr ""
-#: templates/part.eventform.php:65 templates/part.eventinfo.php:44
+#: templates/part.eventform.php:59
+msgid "Advanced options"
+msgstr ""
+
+#: templates/part.eventform.php:64
msgid "Repeat"
msgstr ""
-#: templates/part.eventform.php:81 templates/part.eventinfo.php:51
+#: templates/part.eventform.php:80
msgid "Attendees"
msgstr ""
+#: templates/part.eventform.php:87
+msgid "Location"
+msgstr ""
+
#: templates/part.eventform.php:89
+msgid "Location of the Event"
+msgstr ""
+
+#: templates/part.eventform.php:95
+msgid "Description"
+msgstr ""
+
+#: templates/part.eventform.php:96
msgid "Description of the Event"
msgstr ""
-#: templates/part.eventinfo.php:63
-msgid "Close"
+#: templates/part.import.php:1
+msgid "Import Ical File"
+msgstr ""
+
+#: templates/part.import.php:4
+msgid "How to import the new calendar?"
+msgstr ""
+
+#: templates/part.import.php:6
+msgid "Import into an existing calendar"
+msgstr ""
+
+#: templates/part.import.php:7
+msgid "Import into a new calendar"
+msgstr ""
+
+#: templates/part.import.php:10
+msgid "Please choose the calendar"
+msgstr ""
+
+#: templates/part.import.php:20 templates/part.import.php:37
+msgid "Import"
+msgstr ""
+
+#: templates/part.import.php:22 templates/part.import.php:39
+msgid "Back"
+msgstr ""
+
+#: templates/part.import.php:25
+msgid "Please fill out the form"
msgstr ""
#: templates/part.newevent.php:1
msgid "Create a new event"
msgstr ""
-#: templates/settings.php:11
+#: templates/settings.php:13
msgid "Timezone"
msgstr ""
+
+#: templates/settings.php:32
+msgid "Timeformat"
+msgstr ""
+
+#: templates/settings.php:34
+msgid "24h"
+msgstr ""
+
+#: templates/settings.php:35
+msgid "12h"
+msgstr ""
+
+#: templates/settings.php:41
+msgid "Calendar CalDAV syncing address:"
+msgstr ""
diff --git a/lib/app.php b/lib/app.php
index 30ebcf032b..b1aa8ba354 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -100,11 +100,11 @@ class OC_App{
}
/**
- * @brief enables an app
+ * @brief disables an app
* @param $app app
* @returns true/false
*
- * This function set an app as enabled in appconfig.
+ * This function set an app as disabled in appconfig.
*/
public static function disable( $app ){
OC_Appconfig::setValue( $app, 'enabled', 'no' );
@@ -223,7 +223,7 @@ class OC_App{
// admin apps menu
$settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "settings", "apps.php?installed" ), "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" ));
// admin log menu
- $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "log", "apps.svg" ));
+ $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "settings", "log.svg" ));
$settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "admin.php" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" ));
}
diff --git a/lib/base.php b/lib/base.php
index d5fff1e0a7..700236c96c 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -77,6 +77,9 @@ class OC{
// set some stuff
//ob_start();
error_reporting(E_ALL | E_STRICT);
+ if (defined('DEBUG') && DEBUG){
+ ini_set('display_errors', 1);
+ }
date_default_timezone_set('Europe/Berlin');
ini_set('arg_separator.output','&');
@@ -89,6 +92,14 @@ class OC{
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
+ //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
+ if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
+ {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
// calculate the documentroot
OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
diff --git a/lib/config.php b/lib/config.php
index 2c82036257..8d03271b3e 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -94,7 +94,6 @@ class OC_Config{
// Write changes
self::writeData();
-
return true;
}
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index b049f39c17..98661dbb18 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -29,7 +29,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*/
public function get() {
- return OC_Filesystem::file_get_contents($this->path);
+ return OC_Filesystem::fopen($this->path,'r');
}
diff --git a/lib/db.php b/lib/db.php
index 421b08c232..bcfe320665 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -224,6 +224,7 @@ class OC_DB {
/**
* @brief gets last value of autoincrement
+ * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
* @returns id
*
* MDB2 lastInsertID()
@@ -231,9 +232,14 @@ class OC_DB {
* Call this method right after the insert command or other functions may
* cause trouble!
*/
- public static function insertid(){
+ public static function insertid($table=null){
self::connect();
- return self::$connection->lastInsertId();
+ if($table !== null){
+ $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
+ $suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
+ $table = str_replace( '*PREFIX*', $prefix, $table );
+ }
+ return self::$connection->lastInsertId($table.$suffix);
}
/**
@@ -486,7 +492,7 @@ class PDOStatementWrapper{
}
/**
- * make exucute return the result instead of a bool
+ * make execute return the result instead of a bool
*/
public function execute($input=array()){
$this->lastArguments=$input;
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 01523b6b0b..9e29f85071 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -84,6 +84,11 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $return;
}
public function rename($path1,$path2){
+ if(! $this->file_exists($path1)){
+ OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR);
+ return false;
+ }
+
if($return=rename($this->datadir.$path1,$this->datadir.$path2)){
$this->clearFolderSizeCache($path1);
$this->clearFolderSizeCache($path2);
diff --git a/lib/helper.php b/lib/helper.php
index 5b3e394caf..24d436225b 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -160,24 +160,25 @@ class OC_Helper {
*/
public static function computerFileSize( $str ){
$bytes = 0;
+ $str=strtolower($str);
$bytes_array = array(
- 'B' => 1,
- 'K' => 1024,
- 'KB' => 1024,
- 'MB' => 1024 * 1024,
- 'M' => 1024 * 1024,
- 'GB' => 1024 * 1024 * 1024,
- 'G' => 1024 * 1024 * 1024,
- 'TB' => 1024 * 1024 * 1024 * 1024,
- 'T' => 1024 * 1024 * 1024 * 1024,
- 'PB' => 1024 * 1024 * 1024 * 1024 * 1024,
- 'P' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'b' => 1,
+ 'k' => 1024,
+ 'kb' => 1024,
+ 'mb' => 1024 * 1024,
+ 'm' => 1024 * 1024,
+ 'gb' => 1024 * 1024 * 1024,
+ 'g' => 1024 * 1024 * 1024,
+ 'tb' => 1024 * 1024 * 1024 * 1024,
+ 't' => 1024 * 1024 * 1024 * 1024,
+ 'pb' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'p' => 1024 * 1024 * 1024 * 1024 * 1024,
);
$bytes = floatval($str);
- if (preg_match('#([KMGTP]?B?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
+ if (preg_match('#([kmgtp]?b?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
$bytes *= $bytes_array[$matches[1]];
}
diff --git a/lib/hook.php b/lib/hook.php
index b069a7da6c..83a16106bf 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -20,7 +20,7 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ){
- // Cerate the data structure
+ // Create the data structure
if( !array_key_exists( $signalclass, self::$registered )){
self::$registered[$signalclass] = array();
}
diff --git a/lib/l10n.php b/lib/l10n.php
index 54331d44ae..a5544eb3a2 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -109,6 +109,22 @@ class OC_L10N{
return vsprintf($text, $parameters);
}
+ /**
+ * @brief Translating
+ * @param $textArray The text array we need a translation for
+ * @returns Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $textArray will be
+ * returned.
+ */
+ public function tA($textArray){
+ $result = array();
+ foreach($textArray as $key => $text){
+ $result[$key] = $this->t($text);
+ }
+ return $result;
+ }
+
/**
* @brief getTranslations
* @returns Fetch all translations
diff --git a/lib/log.php b/lib/log.php
index 98333be54f..446ddd4884 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -59,6 +59,9 @@ class OC_Log{
return array();
}
$fh=fopen($logFile,'r');
+ if($fh === false){ // Unable to read log file!
+ return array();
+ }
while(!feof($fh)){
$line=fgets($fh);
if($line){
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 654c5e0527..072fd236fe 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -108,6 +108,7 @@ class OC_OCSClient{
$xml=@file_get_contents($url);
if($xml==FALSE){
+ OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
return NULL;
}
$data=simplexml_load_string($xml);
@@ -143,6 +144,7 @@ class OC_OCSClient{
$kbe=array();
$xml=@file_get_contents($url);
if($xml==FALSE){
+ OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL);
return NULL;
}
$data=simplexml_load_string($xml);
diff --git a/lib/setup.php b/lib/setup.php
index 2dcedb9b82..8afe0070e9 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -77,12 +77,14 @@ class OC_Setup {
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
+ OC_Config::setValue('installedat',microtime(true));
+ OC_Config::setValue('lastupdatedat',microtime(true));
if($dbtype == 'mysql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
- $dbtableprefix = OC_Config::getValue('dbtableprefix','oc_');
+ $dbtableprefix = $options['dbtableprefix'];
OC_Config::setValue('dbname', $dbname);
OC_Config::setValue('dbhost', $dbhost);
OC_Config::setValue('dbtableprefix', $dbtableprefix);
@@ -135,7 +137,7 @@ class OC_Setup {
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
- $dbtableprefix = OC_Config::getValue('dbtableprefix','oc_');
+ $dbtableprefix = $options['dbtableprefix'];
OC_CONFIG::setValue('dbname', $dbname);
OC_CONFIG::setValue('dbhost', $dbhost);
OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
diff --git a/lib/template.php b/lib/template.php
index 440b62003e..881d2a27b1 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -98,6 +98,33 @@ function relative_modified_date($timestamp) {
else { return $l->t('years ago'); }
}
+function html_select_options($options, $selected, $params=array()) {
+ if (!is_array($selected)){
+ $selected=array($selected);
+ }
+ if (isset($params['combine']) && $params['combine']){
+ $options = array_combine($options, $options);
+ }
+ $value_name = $label_name = false;
+ if (isset($params['value'])){
+ $value_name = $params['value'];
+ }
+ if (isset($params['label'])){
+ $label_name = $params['label'];
+ }
+ $html = '';
+ foreach($options as $value => $label){
+ if ($value_name && is_array($label)){
+ $value = $label[$value_name];
+ }
+ if ($label_name && is_array($label)){
+ $label = $label[$label_name];
+ }
+ $select = in_array($value, $selected) ? ' selected="selected"' : '';
+ $html .= '' . $label . ' '."\n";
+ }
+ return $html;
+}
/**
* This class provides the templates for owncloud.
diff --git a/lib/updater.php b/lib/updater.php
new file mode 100644
index 0000000000..cc4a460253
--- /dev/null
+++ b/lib/updater.php
@@ -0,0 +1,81 @@
+.
+ *
+ */
+
+/**
+ * Class that handels autoupdating of ownCloud
+ */
+class OC_Updater{
+
+ /**
+ * Check if a new version is available
+ */
+ public static function check(){
+ OC_Config::setValue('lastupdatedat',microtime(true));
+
+ $updaterurl='http://apps.owncloud.com/updater.php';
+ $version=OC_Util::getVersion();
+ $version['installed']=OC_Config::getValue( "installedat");
+ $version['updated']=OC_Config::getValue( "lastupdatedat");
+ $version['updatechannel']='stable';
+ $versionstring=implode('x',$version);
+
+ //fetch xml data from updater
+ $url=$updaterurl.'?version='.$versionstring;
+ $xml=@file_get_contents($url);
+ if($xml==FALSE){
+ return array();
+ }
+ $data=@simplexml_load_string($xml);
+
+ $tmp=array();
+ $tmp['version'] = $data->version;
+ $tmp['versionstring'] = $data->versionstring;
+ $tmp['url'] = $data->url;
+ $tmp['web'] = $data->web;
+
+ return $tmp;
+ }
+
+ public static function ShowUpdatingHint(){
+ $data=OC_Updater::check();
+ if(isset($data['version']) and $data['version']<>'') {
+ $txt=''.$data['versionstring'].' is available. Please click here for more information ';
+ }else{
+ $txt='Your ownCloud is up to date';
+ }
+ return($txt);
+ }
+
+ /**
+ * do ownCloud update
+ */
+ public static function doUpdate(){
+
+ //update ownCloud core
+
+ //update all apps
+
+ //update version in config
+
+ }
+}
+?>
diff --git a/lib/util.php b/lib/util.php
index 14313569a1..0f79948bc2 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -180,7 +180,6 @@ class OC_Util {
}
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" );
- $serverUser=OC_Util::checkWebserverUser();
//common hint for all file permissons error messages
$permissionsHint="Permissions can usually be fixed by giving the webserver write access to the ownCloud directory";
@@ -239,21 +238,6 @@ class OC_Util {
OC_Template::printGuestPage("", "login", $parameters);
}
- /**
- * Try to get the username the httpd server runs on, used in hints
- */
- public static function checkWebserverUser(){
- if(is_callable('posix_getuid')){
- $serverUser=posix_getpwuid(posix_getuid());
- $serverUser='\''.$serverUser['name'].'\'';
- }elseif(exec('whoami')){
- $serverUser=exec('whoami');
- }else{
- $serverUser='\'www-data\' for ubuntu/debian'; //TODO: try to detect the distro and give a guess based on that
- }
- return $serverUser;
- }
-
/**
* Check if the app is enabled, send json error msg if not
diff --git a/lib/vobject.php b/lib/vobject.php
new file mode 100644
index 0000000000..e3479fc6d3
--- /dev/null
+++ b/lib/vobject.php
@@ -0,0 +1,207 @@
+.
+ *
+ */
+
+/**
+ * This class provides a streamlined interface to the Sabre VObject classes
+ */
+class OC_VObject{
+ /** @var Sabre_VObject_Component */
+ protected $vobject;
+
+ /**
+ * @returns Sabre_VObject_Component
+ */
+ public function getVObject(){
+ return $this->vobject;
+ }
+
+ /**
+ * @brief Parses the VObject
+ * @param string VObject as string
+ * @returns Sabre_VObject or null
+ */
+ public static function parse($data){
+ try {
+ Sabre_VObject_Reader::$elementMap['LAST-MODIFIED'] = 'Sabre_VObject_Element_DateTime';
+ $vobject = Sabre_VObject_Reader::read($data);
+ if ($vobject instanceof Sabre_VObject_Component){
+ $vobject = new OC_VObject($vobject);
+ }
+ return $vobject;
+ } catch (Exception $e) {
+ OC_Log::write('vobject', $e->getMessage(), OC_Log::ERROR);
+ return null;
+ }
+ }
+
+ /**
+ * @brief Escapes semicolons
+ * @param string $value
+ * @return string
+ */
+ public static function escapeSemicolons($value){
+ foreach($value as &$i ){
+ $i = implode("\\\\;", explode(';', $i));
+ }
+ return implode(';',$value);
+ }
+
+ /**
+ * @brief Creates an array out of a multivalue property
+ * @param string $value
+ * @return array
+ */
+ public static function unescapeSemicolons($value){
+ $array = explode(';',$value);
+ for($i=0;$ivobject = $vobject_or_name;
+ } else {
+ $this->vobject = new Sabre_VObject_Component($vobject_or_name);
+ }
+ }
+
+ public function add($item, $itemValue = null){
+ if ($item instanceof OC_VObject){
+ $item = $item->getVObject();
+ }
+ $this->vobject->add($item, $itemValue);
+ }
+
+ /**
+ * @brief Add property to vobject
+ * @param object $name of property
+ * @param object $value of property
+ * @param object $parameters of property
+ * @returns Sabre_VObject_Property newly created
+ */
+ public function addProperty($name, $value, $parameters=array()){
+ if(is_array($value)){
+ $value = OC_VObject::escapeSemicolons($value);
+ }
+ $property = new Sabre_VObject_Property( $name, $value );
+ foreach($parameters as $name => $value){
+ $property->parameters[] = new Sabre_VObject_Parameter($name, $value);
+ }
+
+ $this->vobject->add($property);
+ return $property;
+ }
+
+ public function setUID(){
+ $uid = substr(md5(rand().time()),0,10);
+ $this->vobject->add('UID',$uid);
+ }
+
+ public function setString($name, $string){
+ if ($string != ''){
+ $string = strtr($string, array("\r\n"=>"\n"));
+ $this->vobject->__set($name, $string);
+ }else{
+ $this->vobject->__unset($name);
+ }
+ }
+
+ /**
+ * Sets or unsets the Date and Time for a property.
+ * When $datetime is set to 'now', use the current time
+ * When $datetime is null, unset the property
+ *
+ * @param string property name
+ * @param DateTime $datetime
+ * @param int $dateType
+ * @return void
+ */
+ public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Element_DateTime::LOCALTZ){
+ if ($datetime == 'now'){
+ $datetime = new DateTime();
+ }
+ if ($datetime instanceof DateTime){
+ $datetime_element = new Sabre_VObject_Element_DateTime($name);
+ $datetime_element->setDateTime($datetime, $dateType);
+ $this->vobject->__set($name, $datetime_element);
+ }else{
+ $this->vobject->__unset($name);
+ }
+ }
+
+ public function getAsString($name){
+ return $this->vobject->__isset($name) ?
+ $this->vobject->__get($name)->value :
+ '';
+ }
+
+ public function getAsArray($name){
+ $values = array();
+ if ($this->vobject->__isset($name)){
+ $values = explode(',', $this->getAsString($name));
+ $values = array_map('trim', $values);
+ }
+ return $values;
+ }
+
+ public function &__get($name){
+ if ($name == 'children'){
+ return $this->vobject->children;
+ }
+ $return = $this->vobject->__get($name);
+ if ($return instanceof Sabre_VObject_Component){
+ $return = new OC_VObject($return);
+ }
+ return $return;
+ }
+
+ public function __set($name, $value){
+ return $this->vobject->__set($name, $value);
+ }
+
+ public function __unset($name){
+ return $this->vobject->__unset($name);
+ }
+
+ public function __isset($name){
+ return $this->vobject->__isset($name);
+ }
+
+ public function __call($function,$arguments){
+ return call_user_func_array(array($this->vobject, $function), $arguments);
+ }
+}
diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php
index edbf5b7451..5c07285cfc 100644
--- a/settings/ajax/setquota.php
+++ b/settings/ajax/setquota.php
@@ -10,6 +10,6 @@ $quota= OC_Helper::computerFileSize($_POST["quota"]);
// Return Success story
OC_Preferences::setValue($username,'files','quota',$quota);
-OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
+OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>OC_Helper::humanFileSize($quota))));
?>
diff --git a/settings/apps.php b/settings/apps.php
index 27b4c17f9e..12a7bf7720 100644
--- a/settings/apps.php
+++ b/settings/apps.php
@@ -43,6 +43,14 @@ foreach($registeredApps as $app){
}
}
+function app_sort($a, $b){
+ if ($a['active'] != $b['active']){
+ return $b['active'] - $a['active'];
+ }
+ return strcmp($a['name'], $b['name']);
+}
+usort($apps, 'app_sort');
+
// dissabled for now
// $catagoryNames=OC_OCSClient::getCategories();
// if(is_array($catagoryNames)){
diff --git a/settings/js/users.js b/settings/js/users.js
index 684fee21c6..4fea52e4a1 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -101,8 +101,11 @@ $(document).ready(function(){
if($(this).val().length>0){
$.post(
OC.filePath('settings','ajax','setquota.php'),
- {username:uid,quota:$(this).val()},
- function(result){}
+ {username:uid,quota:$(this).val()},
+ function(result){
+ img.parent().children('span').text(result.data.quota)
+ $(this).parent().attr('data-quota',result.data.quota);
+ }
);
input.blur();
}else{
diff --git a/settings/templates/help.php b/settings/templates/help.php
index 4e3cdd7b90..754bf8b637 100644
--- a/settings/templates/help.php
+++ b/settings/templates/help.php
@@ -9,7 +9,10 @@
printPage();
+ if($pageNavi)
+ {
+ $pageNavi->printPage();
+ }
?>
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 54487165f3..8c5de5ccf2 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -50,7 +50,9 @@
};?>
- ownCloud , source code licensed freely under AGPL
+ ownCloud
+
+ source code licensed freely under AGPL