Merge branch 'master' of git://gitorious.org/owncloud/owncloud

This commit is contained in:
Marvin Thomas Rabe 2011-10-02 15:38:51 +02:00
commit ba49bcd5a9
13 changed files with 283 additions and 72 deletions

View File

@ -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));
?>

View File

@ -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
?>

View File

@ -29,35 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
$starttime = '0'; $starttime = '0';
$startminutes = '00'; $startminutes = '00';
}else{ }else{
$starttime = date('H'); $starttime = date('G');
if(strlen($starttime) == 2 && $starttime <= 9){
$starttime = substr($starttime, 1, 1);
}
$startminutes = date('i'); $startminutes = date('i');
} }
$endday = $startday; $datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
$endmonth = $startmonth; $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
$endyear = $startyear; $datetimestamp = $datetimestamp + ($duration * 60);
$endtime = $starttime; $endmonth = date("m", $datetimestamp);
$endminutes = $startminutes; $endday = date("d", $datetimestamp);
if($endtime == 23) { $endyear = date("Y", $datetimestamp);
if($startday == date(t, mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear))){ $endtime = date("G", $datetimestamp);
$datetimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear); $endminutes = date("i", $datetimestamp);
$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++;
}
$tmpl = new OC_Template('calendar', 'part.newevent'); $tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options); $tmpl->assign('calendar_options', $calendar_options);

View File

@ -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();
}
?>

View File

@ -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();
}
?>

View File

@ -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));
?>

View File

@ -10,15 +10,29 @@ require_once ("../../lib/base.php");
OC_Util::checkLoggedIn(); OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar'); OC_Util::checkAppEnabled('calendar');
$cal = $_GET["calid"]; $cal = $_GET["calid"];
$calendar = OC_Calendar_Calendar::findCalendar($cal); $event = $_GET["eventid"];
if($calendar["userid"] != OC_User::getUser()){ if(isset($cal)){
header( 'Location: '.OC_Helper::linkTo('', 'index.php')); $calendar = OC_Calendar_Calendar::findCalendar($cal);
if($calendar["userid"] != OC_User::getUser()){
OC_JSON::error();
exit; exit;
} }
$calobjects = OC_Calendar_Object::all($cal); $calobjects = OC_Calendar_Object::all($cal);
header("Content-Type: text/Calendar"); header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics"); header("Content-Disposition: inline; filename=calendar.ics");
for($i = 0;$i <= count($calobjects); $i++){ for($i = 0;$i <= count($calobjects); $i++){
echo $calobjects[$i]["calendardata"] . "\n"; 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"];
} }
?> ?>

View File

@ -155,6 +155,7 @@ Calendar={
Calendar.UI.updateView() Calendar.UI.updateView()
}); });
}, },
drageventid: '',
updateDate:function(direction){ updateDate:function(direction){
if(direction == 'forward' && this.current.forward) { if(direction == 'forward' && this.current.forward) {
this.current.forward(); this.current.forward();
@ -247,6 +248,11 @@ Calendar={
.data('event_info', event) .data('event_info', event)
.hover(this.createEventPopup, .hover(this.createEventPopup,
this.hideEventPopup) this.hideEventPopup)
.draggable({
drag: function() {
Calendar.UI.drageventid = event.id;
}
})
.click(this.editEvent); .click(this.editEvent);
var color = this.calendars[event['calendarid']]['color']; var color = this.calendars[event['calendarid']]['color'];
if (color){ if (color){
@ -360,6 +366,12 @@ Calendar={
} }
},"json"); },"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(){ showadvancedoptions:function(){
$("#advanced_options").css("display", "block"); $("#advanced_options").css("display", "block");
$("#advanced_options_button").css("display", "none"); $("#advanced_options_button").css("display", "none");
@ -548,6 +560,22 @@ Calendar={
var today = new Date(); var today = new Date();
for(var i = 0; i <= 6; i++){ 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 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()){ if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
$("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday"); $("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
} }
@ -724,6 +752,13 @@ Calendar={
var month = dates[i].getMonth(); var month = dates[i].getMonth();
var year = dates[i].getFullYear(); 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] + " .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()){ if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday'); $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
} }

View File

@ -34,6 +34,29 @@ $(document).ready(function(){
minWidth:'auto', 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(){ $("#weekend").change( function(){
var data = $("#weekend").serialize(); var data = $("#weekend").serialize();
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){

View File

@ -1,32 +1,4 @@
<?php <?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( $hours24 = array(
'allday' => $l->t('All day'), 'allday' => $l->t('All day'),
0 => '0', 0 => '0',
@ -81,7 +53,11 @@ $hoursampm = array(
22 => '10 p.m.', 22 => '10 p.m.',
23 => '11 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'); $weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); $dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
$weekdays = array(); $weekdays = array();

View File

@ -6,6 +6,7 @@
<span id="actions"> <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;" 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: 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> </span>
</form> </form>
</div> </div>

View File

@ -38,14 +38,21 @@ OC_UTIL::addStyle('', 'jquery.multiselect');
?> ?>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label> <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 <?php
$weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
for($i = 0;$i <= 6;$i++){ for($i = 0;$i <= 6;$i++){
echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>'; echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>';
} }
?> ?>
</select> </select>&nbsp;&nbsp;
<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>&nbsp;&nbsp;
<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 /> <br />
Calendar CalDAV syncing address: Calendar CalDAV syncing address:
<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br /> <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />

View File

@ -101,6 +101,17 @@ class OC_Appconfig{
} }
} }
/**
* @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 * @brief sets a value in the appconfig
* @param $app app * @param $app app
@ -112,10 +123,7 @@ class OC_Appconfig{
*/ */
public static function setValue( $app, $key, $value ){ public static function setValue( $app, $key, $value ){
// Does the key exist? yes: update. No: insert // Does the key exist? yes: update. No: insert
$exists = self::getKeys( $app ); if(! self::hasKey($app,$key)){
// null: does not exist
if( !in_array( $key, $exists )){
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' ); $query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
$query->execute( array( $app, $key, $value )); $query->execute( array( $app, $key, $value ));
} }