Calendar: Correct calendarcolor format for ical color property

This commit is contained in:
Bart Visscher 2012-02-21 20:10:40 +01:00
parent 987845c312
commit 86d2927c02
5 changed files with 40 additions and 15 deletions

View File

@ -25,8 +25,16 @@ foreach($calendars as $cal){
}
$calendarid = $_POST['id'];
$calendarcolor = $_POST['color'];
if (preg_match('/^#?([0-9a-f]{6})/', $calendarcolor, $matches)) {
$calendarcolor = '#'.$matches[1];
}
else {
$calendarcolor = null;
}
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $calendarcolor);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_App::getCalendar($calendarid);

View File

@ -2,7 +2,7 @@
<info>
<id>calendar</id>
<name>Calendar</name>
<version>0.2</version>
<version>0.2.1</version>
<licence>AGPL</licence>
<author>Georg Ehrke, Bart Visscher, Jakob Sack</author>
<require>2</require>

View File

@ -0,0 +1,17 @@
<?php
$installedVersion=OC_Appconfig::getValue('calendar', 'installed_version');
if (version_compare($installedVersion, '0.2.1', '<')) {
$stmt = OC_DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' );
$result = $stmt->execute();
while( $row = $result->fetchRow()) {
$id = $row['id'];
$color = $row['calendarcolor'];
if ($color[0] == '#' || strlen($color) < 6) {
continue;
}
$color = '#' .$color;
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' );
$r = $stmt->execute(array($color,$id));
}
}

View File

@ -478,7 +478,7 @@ Calendar={
colors[i].label = $(elm).text();
});
for (var i in colors) {
picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + ';"></span>');
picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: ' + colors[i].color + ';"></span>');
}
picker.delegate(".calendar-colorpicker-color", "click", function() {
$(obj).val($(this).attr('rel'));

View File

@ -96,7 +96,7 @@ class OC_Calendar_Calendar{
* @param string $components Default: "VEVENT,VTODO,VJOURNAL"
* @param string $timezone Default: null
* @param integer $order Default: 1
* @param string $color Default: null
* @param string $color Default: null, format: '#RRGGBB(AA)'
* @return insertid
*/
public static function addCalendar($userid,$name,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null){
@ -122,7 +122,7 @@ class OC_Calendar_Calendar{
* @param string $components
* @param string $timezone
* @param integer $order
* @param string $color
* @param string $color format: '#RRGGBB(AA)'
* @return insertid
*/
public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){
@ -141,7 +141,7 @@ class OC_Calendar_Calendar{
* @param string $components Default: null
* @param string $timezone Default: null
* @param integer $order Default: null
* @param string $color Default: null
* @param string $color Default: null, format: '#RRGGBB(AA)'
* @return boolean
*
* Values not null will be set
@ -230,20 +230,20 @@ class OC_Calendar_Calendar{
}
public static function getCalendarColorOptions(){
return array(
'ff0000', // "Red"
'b3dc6c', // "Green"
'ffff00', // "Yellow"
'808000', // "Olive"
'ffa500', // "Orange"
'ff7f50', // "Coral"
'ee82ee', // "Violet"
'9fc6e7', // "light blue"
'#ff0000', // "Red"
'#b3dc6c', // "Green"
'#ffff00', // "Yellow"
'#808000', // "Olive"
'#ffa500', // "Orange"
'#ff7f50', // "Coral"
'#ee82ee', // "Violet"
'#9fc6e7', // "light blue"
);
}
public static function getEventSourceInfo($calendar){
return array(
'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
'backgroundColor' => '#'.$calendar['calendarcolor'],
'backgroundColor' => $calendar['calendarcolor'],
'borderColor' => '#888',
'textColor' => 'black',
'cache' => true,