Merge branch 'master' of git://gitorious.org/owncloud/owncloud
This commit is contained in:
commit
ba49bcd5a9
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* 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();
|
||||
$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
|
||||
OC_JSON::encodedPrint(array("duration" => $duration));
|
||||
?>
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* 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;
|
||||
$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;
|
||||
}
|
||||
$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);
|
||||
}
|
||||
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);
|
||||
|
||||
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
||||
OC_JSON::success();
|
||||
//end part of editevent.php
|
||||
?>
|
|
@ -29,35 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
|
|||
$starttime = '0';
|
||||
$startminutes = '00';
|
||||
}else{
|
||||
$starttime = date('H');
|
||||
if(strlen($starttime) == 2 && $starttime <= 9){
|
||||
$starttime = substr($starttime, 1, 1);
|
||||
}
|
||||
$starttime = date('G');
|
||||
|
||||
$startminutes = date('i');
|
||||
}
|
||||
|
||||
$endday = $startday;
|
||||
$endmonth = $startmonth;
|
||||
$endyear = $startyear;
|
||||
$endtime = $starttime;
|
||||
$endminutes = $startminutes;
|
||||
if($endtime == 23) {
|
||||
if($startday == date(t, mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear))){
|
||||
$datetimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear);
|
||||
$datetimestamp = $datetimestamp + 86400;
|
||||
$endmonth = date("m", $datetimestamp);
|
||||
$endday = date("d", $datetimestamp);
|
||||
$endyear = date("Y", $datetimestamp);
|
||||
}else{
|
||||
$endday++;
|
||||
if($endday <= 9){
|
||||
$endday = "0" . $endday;
|
||||
}
|
||||
}
|
||||
$endtime = 0;
|
||||
} else {
|
||||
$endtime++;
|
||||
}
|
||||
$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);
|
||||
|
||||
|
||||
|
||||
$tmpl = new OC_Template('calendar', 'part.newevent');
|
||||
$tmpl->assign('calendar_options', $calendar_options);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* 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();
|
||||
if(isset($_POST["duration"])){
|
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]);
|
||||
OC_JSON::success();
|
||||
}else{
|
||||
OC_JSON::error();
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* 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();
|
||||
if(isset($_POST["timeformat"])){
|
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
|
||||
OC_JSON::success();
|
||||
}else{
|
||||
OC_JSON::error();
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* 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();
|
||||
$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
|
||||
OC_JSON::encodedPrint(array("timeformat" => $timeformat));
|
||||
?>
|
|
@ -10,15 +10,29 @@ require_once ("../../lib/base.php");
|
|||
OC_Util::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
$cal = $_GET["calid"];
|
||||
$calendar = OC_Calendar_Calendar::findCalendar($cal);
|
||||
if($calendar["userid"] != OC_User::getUser()){
|
||||
header( 'Location: '.OC_Helper::linkTo('', 'index.php'));
|
||||
exit;
|
||||
}
|
||||
$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";
|
||||
$event = $_GET["eventid"];
|
||||
if(isset($cal)){
|
||||
$calendar = OC_Calendar_Calendar::findCalendar($cal);
|
||||
if($calendar["userid"] != OC_User::getUser()){
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
$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";
|
||||
}
|
||||
}elseif(isset($event)){
|
||||
$data = OC_Calendar_Object::find($_GET["eventid"]);
|
||||
$calendarid = $data["calendarid"];
|
||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
||||
if($calendar["userid"] != OC_User::getUser()){
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
header("Content-Type: text/Calendar");
|
||||
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
|
||||
echo $data["calendardata"];
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -155,6 +155,7 @@ Calendar={
|
|||
Calendar.UI.updateView()
|
||||
});
|
||||
},
|
||||
drageventid: '',
|
||||
updateDate:function(direction){
|
||||
if(direction == 'forward' && this.current.forward) {
|
||||
this.current.forward();
|
||||
|
@ -247,6 +248,11 @@ Calendar={
|
|||
.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){
|
||||
|
@ -360,6 +366,12 @@ Calendar={
|
|||
}
|
||||
},"json");
|
||||
},
|
||||
moveevent:function(eventid, newstartdate){
|
||||
$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate},
|
||||
function(data) {
|
||||
console.log("Event moved successfully");
|
||||
});
|
||||
},
|
||||
showadvancedoptions:function(){
|
||||
$("#advanced_options").css("display", "block");
|
||||
$("#advanced_options_button").css("display", "none");
|
||||
|
@ -548,6 +560,22 @@ Calendar={
|
|||
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");
|
||||
}
|
||||
|
@ -724,6 +752,13 @@ Calendar={
|
|||
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');
|
||||
}
|
||||
|
|
|
@ -34,6 +34,29 @@ $(document).ready(function(){
|
|||
minWidth:'auto',
|
||||
});
|
||||
});
|
||||
$("#timeformat").change( function(){
|
||||
var data = $("#timeformat").serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
|
||||
if(data == "error"){
|
||||
console.log("saving timeformat failed");
|
||||
}
|
||||
});
|
||||
});
|
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
|
||||
$("#" + jsondata.timeformat).attr('selected',true);
|
||||
$("#timeformat").chosen();
|
||||
});
|
||||
$("#duration").blur( function(){
|
||||
var data = $("#duration").val();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){
|
||||
if(data == "error"){
|
||||
console.log("saving duration failed");
|
||||
}
|
||||
});
|
||||
});
|
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
|
||||
$("#duration").val(jsondata.duration);
|
||||
});
|
||||
$("#weekend").change( function(){
|
||||
var data = $("#weekend").serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
|
||||
|
|
|
@ -1,32 +1,4 @@
|
|||
<?php
|
||||
$hours = array(
|
||||
'allday' => $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',
|
||||
);
|
||||
/*
|
||||
$hours24 = array(
|
||||
'allday' => $l->t('All day'),
|
||||
0 => '0',
|
||||
|
@ -81,7 +53,11 @@ $hoursampm = array(
|
|||
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();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<span id="actions">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
|
||||
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');">
|
||||
<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -38,14 +38,21 @@ OC_UTIL::addStyle('', 'jquery.multiselect');
|
|||
?>
|
||||
</select>
|
||||
<label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label>
|
||||
<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo "Wochenende"; ?>">
|
||||
<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>">
|
||||
<?php
|
||||
$weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
|
||||
for($i = 0;$i <= 6;$i++){
|
||||
echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</select>
|
||||
<label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label>
|
||||
<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
|
||||
<option value="24" id="24h"><?php echo $l->t("24 h"); ?></option>
|
||||
<option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></option>
|
||||
</select>
|
||||
<label for="duration"><strong><?php echo $l->t('Event duration');?></strong></label>
|
||||
<input type="text" maxlength="3" size="3" style="width: 2em;" id="duration" name="duration" /> <strong><?php echo $l->t("Minutes");?></strong>
|
||||
<br />
|
||||
Calendar CalDAV syncing address:
|
||||
<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
|
||||
|
|
|
@ -100,7 +100,18 @@ class OC_Appconfig{
|
|||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief check if a key is set in the appconfig
|
||||
* @param string $app
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasKey($app,$key){
|
||||
$exists = self::getKeys( $app );
|
||||
return in_array( $key, $exists );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sets a value in the appconfig
|
||||
* @param $app app
|
||||
|
@ -112,10 +123,7 @@ class OC_Appconfig{
|
|||
*/
|
||||
public static function setValue( $app, $key, $value ){
|
||||
// Does the key exist? yes: update. No: insert
|
||||
$exists = self::getKeys( $app );
|
||||
|
||||
// null: does not exist
|
||||
if( !in_array( $key, $exists )){
|
||||
if(! self::hasKey($app,$key)){
|
||||
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
|
||||
$query->execute( array( $app, $key, $value ));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue