Fix merge conflict.

remotes/origin/stable4
Thomas Tanghus 13 years ago
commit 9794e7e427
  1. 10
      apps/calendar/ajax/updatecalendar.php
  2. 2
      apps/calendar/appinfo/info.xml
  3. 17
      apps/calendar/appinfo/update.php
  4. 2
      apps/calendar/js/calendar.js
  5. 24
      apps/calendar/lib/calendar.php
  6. 2
      apps/contacts/ajax/saveproperty.php
  7. 2
      apps/contacts/js/contacts.js
  8. 215
      apps/contacts/lib/vcard.php
  9. 4
      apps/media/css/music.css
  10. 14
      lib/helper.php
  11. 7
      lib/util.php

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

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

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

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

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

@ -51,7 +51,7 @@ $checksum = isset($_POST['checksum'])?$_POST['checksum']:null;
// }
// }
if(is_array($value)){ // FIXME: How to strip_tags for compound values?
if(is_array($value)){
$value = array_map('strip_tags', $value);
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
$value = OC_VObject::escapeSemicolons($value);

@ -1076,7 +1076,7 @@ Contacts={
$.post(url, { id: bookid, name: displayname, active: active, description: description },
function(jsondata){
if(jsondata.status == 'success'){
$(button).closest('tr').prev().html(data.page).show().next().remove();
$(button).closest('tr').prev().html(jsondata.page).show().next().remove();
Contacts.UI.Contacts.update();
} else {
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);

@ -103,6 +103,118 @@ class OC_Contacts_VCard{
return $result->fetchRow();
}
/**
* @brief Format property TYPE parameters for upgrading from v. 2.1
* @param $property Reference to a Sabre_VObject_Property.
* In version 2.1 e.g. a phone can be formatted like: TEL;HOME;CELL:123456789
* This has to be changed to either TEL;TYPE=HOME,CELL:123456789 or TEL;TYPE=HOME;TYPE=CELL:123456789 - both are valid.
*/
public static function formatPropertyTypes(&$property) {
foreach($property->parameters as $key=>&$parameter){
$types = OC_Contacts_App::getTypesOfProperty($property->name);
if(is_array($types) && in_array(strtoupper($parameter->name), array_keys($types)) || strtoupper($parameter->name) == 'PREF') {
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $parameter->name);
}
unset($property->parameters[$key]);
}
}
/**
* @brief Decode properties for upgrading from v. 2.1
* @param $property Reference to a Sabre_VObject_Property.
* The only encoding allowed in version 3.0 is 'b' for binary. All encoded strings
* must therefor be decoded and the parameters removed.
*/
public static function decodeProperty(&$property) {
// Check out for encoded string and decode them :-[
foreach($property->parameters as $key=>&$parameter){
if(strtoupper($parameter->name) == 'ENCODING') {
if(strtoupper($parameter->value) == 'QUOTED-PRINTABLE') { // what kind of other encodings could be used?
$property->value = quoted_printable_decode($property->value);
unset($property->parameters[$key]);
}
} elseif(strtoupper($parameter->name) == 'CHARSET') {
unset($property->parameters[$key]);
}
}
}
/**
* @brief Tries to update imported VCards to adhere to rfc2426 (VERSION: 3.0)
* @param vcard An OC_VObject of type VCARD (passed by reference).
*/
protected static function updateValuesFromAdd(&$vcard) { // any suggestions for a better method name? ;-)
$stringprops = array('N', 'FN', 'ORG', 'NICK', 'ADR', 'NOTE');
$typeprops = array('ADR', 'TEL', 'EMAIL');
$upgrade = false;
$fn = $n = $uid = $email = null;
$version = $vcard->getAsString('VERSION');
// Add version if needed
if($version && $version < '3.0') {
$upgrade = true;
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OC_Log::DEBUG);
}
foreach($vcard->children as &$property){
// Decode string properties and remove obsolete properties.
if($upgrade && in_array($property->name, $stringprops)) {
self::decodeProperty($property);
}
// Fix format of type parameters.
if($upgrade && in_array($property->name, $typeprops)) {
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OC_Log::DEBUG);
self::formatPropertyTypes($property);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OC_Log::DEBUG);
}
if($property->name == 'FN'){
$fn = $property->value;
}
if($property->name == 'N'){
$n = $property->value;
}
if($property->name == 'UID'){
$uid = $property->value;
}
if($property->name == 'EMAIL' && is_null($email)){ // only use the first email as substitute for missing N or FN.
$email = $property->value;
}
}
// Check for missing 'N', 'FN' and 'UID' properties
if(!$fn) {
if($n && $n != ';;;;'){
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
} elseif($email) {
$fn = $email;
} else {
$fn = 'Unknown Name';
}
$vcard->setString('FN', $fn);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OC_Log::DEBUG);
}
if(!$n || $n = ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-)
$slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse.
if(count($slice) < 2) { // If not enought, add one more...
$slice[] = "";
}
$n = implode(';', $slice).';;;';
$vcard->setString('N', $n);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
}
if(!$uid) {
$vcard->setUID();
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OC_Log::DEBUG);
}
$vcard->setString('VERSION','3.0');
// Add product ID is missing.
$prodid = trim($vcard->getAsString('PRODID'));
if(!$prodid) {
$appinfo = OC_App::getAppInfo('contacts');
$prodid = '-//ownCloud//NONSGML '.$appinfo['name'].' '.$appinfo['version'].'//EN';
$vcard->setString('PRODID', $prodid);
}
$now = new DateTime;
$vcard->setString('REV', $now->format(DateTime::W3C));
}
/**
* @brief Adds a card
* @param integer $id Addressbook id
@ -115,59 +227,17 @@ class OC_Contacts_VCard{
$card = OC_VObject::parse($data);
if(!is_null($card)){
OC_Contacts_App::$categories->loadFromVObject($card);
$fn = $card->getAsString('FN');
if(!$fn){ // Fix missing 'FN' field.
$n = $card->getAsString('N');
if(!is_null($n)){
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
$card->setString('FN', $fn);
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'FN\' field: '.$fn,OC_Log::DEBUG);
} else {
$fn = 'Unknown Name';
}
}
$n = $card->getAsString('N');
if(!$n){ // Fix missing 'N' field.
$n = implode(';', array_reverse(array_slice(explode(' ', $fn), 0, 2))).';;;';
$card->setString('N', $n);
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
}
$uid = $card->getAsString('UID');
if(!$uid){
$card->setUID();
$uid = $card->getAsString('UID');
};
$uri = $uid.'.vcf';
// Add product ID.
$prodid = trim($card->getAsString('PRODID'));
if(!$prodid) {
$appinfo = OC_App::getAppInfo('contacts');
$prodid = '//ownCloud//NONSGML '.$appinfo['name'].' '.$appinfo['version'].'//EN';
$card->setString('PRODID', $prodid);
}
// VCARD must have a version
$version = $card->getAsString('VERSION');
// Add version if needed
if(!$version){
$card->add(new Sabre_VObject_Property('VERSION','3.0'));
//$data = $card->serialize();
}/* else {
OC_Log::write('contacts','OC_Contacts_VCard::add. Version already set as: '.$version,OC_Log::DEBUG);
}*/
$now = new DateTime;
$card->setString('REV', $now->format(DateTime::W3C));
self::updateValuesFromAdd($card);
$data = $card->serialize();
}
else{
// that's hard. Creating a UID and not saving it
OC_Log::write('contacts','OC_Contacts_VCard::add. Error parsing VCard: '.$data,OC_Log::ERROR);
return null; // Ditch cards that can't be parsed by Sabre.
//$uid = self::createUID();
//$uri = $uid.'.vcf';
};
$fn = $card->getAsString('FN');
$uid = $card->getAsString('UID');
$uri = $uid.'.vcf';
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
@ -185,55 +255,24 @@ class OC_Contacts_VCard{
* @return insertid
*/
public static function addFromDAVData($id,$uri,$data){
$fn = $n = $uid = null;
$email = null;
$card = OC_VObject::parse($data);
if(!is_null($card)){
OC_Contacts_App::$categories->loadFromVObject($card);
foreach($card->children as $property){
if($property->name == 'FN'){
$fn = $property->value;
}
if($property->name == 'N'){
$n = $property->value;
}
if($property->name == 'UID'){
$uid = $property->value;
}
if($property->name == 'EMAIL' && is_null($email)){
$email = $property->value;
}
}
}
if(!$fn) {
if($n){
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
} elseif($email) {
$fn = $email;
} else {
$fn = 'Unknown Name';
}
$card->addProperty('FN', $fn);
$data = $card->serialize();
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'FN\' field: '.$n,OC_Log::DEBUG);
}
if(!$n){ // Fix missing 'N' field.
$n = implode(';', array_reverse(array_slice(explode(' ', $fn), 0, 2))).';;;';
$card->setString('N', $n);
$data = $card->serialize();
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
}
if(!$uid) {
$card->setUID();
self::updateValuesFromAdd($card);
$data = $card->serialize();
}
} else {
OC_Log::write('contacts','OC_Contacts_VCard::addFromDAVData. Error parsing VCard: '.$data, OC_Log::ERROR);
return null; // Ditch cards that can't be parsed by Sabre.
};
$fn = $card->getAsString('FN');
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
OC_Contacts_Addressbook::touch($id);
return OC_DB::insertid('*PREFIX*contacts_cards');
return $newid;
}
/**
@ -309,7 +348,7 @@ class OC_Contacts_VCard{
* @return boolean
*/
public static function delete($id){
// FIXME: Add error checking. Touch addressbook.
// FIXME: Add error checking.
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
$stmt->execute(array($id));
@ -386,10 +425,14 @@ class OC_Contacts_VCard{
'checksum' => md5($property->serialize()));
foreach($property->parameters as $parameter){
// Faulty entries by kaddressbook
// Actually TYPE=PREF is correct according to RFC 2426
// but this way is more handy in the UI. Tanghus.
if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){
$parameter->name = 'PREF';
$parameter->value = '1';
}
// NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters
// like TYPE=HOME,CELL,VOICE. Tanghus.
if ($property->name == 'TEL' && $parameter->name == 'TYPE'){
if (isset($temp['parameters'][$parameter->name])){
$temp['parameters'][$parameter->name][] = $parameter->value;

@ -17,7 +17,7 @@ a.jp-mute,a.jp-unmute { left:24em; }
div.jp-volume-bar { position:absolute; overflow:hidden; background:#eee; width:4em; height:0.4em; cursor:pointer; top:1.3em; left:27em; }
div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection { padding-top:1em; position:relative; width:100%; float:left; table-layout:fixed; }
#collection { position:relative; width:100%; float:left; table-layout:fixed; }
#collection td { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#leftcontent img.remove { display:none; float:right; cursor:pointer; opacity: 0; }
#leftcontent li:hover img.remove { display:inline; opacity: .3; }
@ -31,7 +31,7 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection td.artist-expander, #collection td.album-expander { width:2em; text-align:center; }
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 td { border-bottom:1px solid #eee; height:2.2em; }
tr .artist img { vertical-align:middle; }
tr.album td.artist { padding-left:1em; }
tr.song td.artist { padding-left:2em; }

@ -29,12 +29,11 @@ class OC_Helper {
* @brief Creates an url
* @param $app app
* @param $file file
* @param $redirect_url redirect_url variable is appended to the URL
* @returns the url
*
* Returns a url to the given app and file.
*/
public static function linkTo( $app, $file, $redirect_url=NULL, $absolute=false ){
public static function linkTo( $app, $file ){
if( $app != '' ){
$app .= '/';
// Check if the app is in the app folder
@ -54,24 +53,19 @@ class OC_Helper {
}
}
if($redirect_url)
return $urlLinkTo.'?redirect_url='.urlencode($_SERVER["REQUEST_URI"]);
else
return $urlLinkTo;
return $urlLinkTo;
}
/**
* @brief Creates an absolute url
* @param $app app
* @param $file file
* @param $redirect_url redirect_url variable is appended to the URL
* @returns the url
*
* Returns a absolute url to the given app and file.
*/
public static function linkToAbsolute( $app, $file, $redirect_url=NULL ) {
$urlLinkTo = self::linkTo( $app, $file, $redirect_url );
public static function linkToAbsolute( $app, $file ) {
$urlLinkTo = self::linkTo( $app, $file );
// Checking if the request was made through HTTPS. The last in line is for IIS
$protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off');
$urlLinkTo = ($protocol?'https':'http') . '://' . $_SERVER['HTTP_HOST'] . $urlLinkTo;

@ -240,7 +240,7 @@ class OC_Util {
/**
* Check if the app is enabled, send json error msg if not
* Check if the app is enabled, redirects to home if not
*/
public static function checkAppEnabled($app){
if( !OC_App::isEnabled($app)){
@ -250,12 +250,13 @@ class OC_Util {
}
/**
* Check if the user is logged in, redirects to home if not
* Check if the user is logged in, redirects to home if not. With
* redirect URL parameter to the request URI.
*/
public static function checkLoggedIn(){
// Check if we are a user
if( !OC_User::isLoggedIn()){
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ));
header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ).'?redirect_url='.urlencode($_SERVER["REQUEST_URI"]));
exit();
}
}

Loading…
Cancel
Save