From bcbebe390b2689de34f60d124d19c9154d531f5e Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:33:39 +0100 Subject: [PATCH 01/70] Document OC_Response --- lib/response.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/response.php b/lib/response.php index 2fa0a5adcd3..3765f509c18 100644 --- a/lib/response.php +++ b/lib/response.php @@ -12,6 +12,13 @@ class OC_Response { const STATUS_TEMPORARY_REDIRECT = 307; const STATUS_NOT_FOUND = 404; + /** + * @brief Enable response caching by sending correct HTTP headers + * @param $cache_time time to cache the response + * >0 cache time in seconds + * 0 and <0 enable default browser caching + * null cache indefinitly + */ static public function enableCaching($cache_time = null) { if (is_numeric($cache_time)) { header('Pragma: public');// enable caching in IE @@ -30,10 +37,19 @@ class OC_Response { } } + + /** + * @brief disable browser caching + * @see enableCaching with cache_time = 0 + */ static public function disableCaching() { self::enableCaching(0); } + /** + * @brief Set response status + * @param $status a HTTP status code, see also the STATUS constants + */ static public function setStatus($status) { $protocol = $_SERVER['SERVER_PROTOCOL']; switch($status) { @@ -58,11 +74,21 @@ class OC_Response { header($protocol.' '.$status); } + /** + * @brief Send redirect response + * @param $location to redirect to + */ static public function redirect($location) { self::setStatus(self::STATUS_TEMPORARY_REDIRECT); header('Location: '.$location); } + /** + * @brief Set reponse expire time + * @param $expires date-time when the response expires + * string for DateInterval from now + * DateTime object when to expire response + */ static public function setExpiresHeader($expires) { if (is_string($expires) && $expires[0] == 'P') { $interval = $expires; @@ -76,6 +102,11 @@ class OC_Response { header('Expires: '.$expires); } + /** + * Checks and set ETag header, when the request matches sends a + * 'not modified' response + * @param $etag token to use for modification check + */ static public function setETagHeader($etag) { if (empty($etag)) { return; @@ -88,6 +119,11 @@ class OC_Response { header('ETag: '.$etag); } + /** + * Checks and set Last-Modified header, when the request matches sends a + * 'not modified' response + * @param $lastModified time when the reponse was last modified + */ static public function setLastModifiedHeader($lastModified) { if (empty($lastModified)) { return; @@ -106,6 +142,10 @@ class OC_Response { header('Last-Modified: '.$lastModified); } + /** + * @brief Send file as response, checking and setting caching headers + * @param $filepath of file to send + */ static public function sendFile($filepath=null) { $fp = fopen($filepath, 'rb'); if ($fp) { From f54c767d72b8380c181c218f378b25e5fbf75ce7 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:35:31 +0100 Subject: [PATCH 02/70] Fix parameter of OC_Response::sendFile --- lib/response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.php b/lib/response.php index 3765f509c18..9edae3603b2 100644 --- a/lib/response.php +++ b/lib/response.php @@ -146,7 +146,7 @@ class OC_Response { * @brief Send file as response, checking and setting caching headers * @param $filepath of file to send */ - static public function sendFile($filepath=null) { + static public function sendFile($filepath) { $fp = fopen($filepath, 'rb'); if ($fp) { self::setLastModifiedHeader(filemtime($filepath)); From 5f3c54922773068091dfe8b40e3b407512ef4cfe Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 16 Feb 2012 19:16:31 +0100 Subject: [PATCH 03/70] Contacts: Add removed app enabled check --- apps/contacts/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/contacts/index.php b/apps/contacts/index.php index c5115d16074..0a21ddd04b6 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -10,6 +10,8 @@ require_once('../../lib/base.php'); // Check if we are a user OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('contacts'); + // Get active address books. This creates a default one if none exists. $ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser()); $contacts = OC_Contacts_VCard::all($ids); From f47444e1f776912cbf141ec9cc3763110f4e3552 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 16 Feb 2012 19:45:00 +0100 Subject: [PATCH 04/70] Use separate function to make absolute urls --- apps/bookmarks/templates/settings.php | 2 +- apps/calendar/templates/calendar.php | 2 +- apps/calendar/templates/settings.php | 2 +- apps/contacts/templates/index.php | 2 +- apps/contacts/templates/part.contactphoto.php | 2 +- apps/contacts/templates/part.cropphoto.php | 4 ++-- apps/contacts/templates/settings.php | 2 +- apps/media/lib_ampache.php | 2 +- apps/media/templates/settings.php | 2 +- apps/user_openid/appinfo/app.php | 4 ++-- apps/user_openid/user.php | 2 +- core/lostpassword/index.php | 2 +- index.php | 2 +- lib/helper.php | 23 ++++++++++++++----- lib/util.php | 6 ++--- settings/templates/personal.php | 2 +- 16 files changed, 36 insertions(+), 25 deletions(-) diff --git a/apps/bookmarks/templates/settings.php b/apps/bookmarks/templates/settings.php index 97b6b256c09..a985ee9d61b 100644 --- a/apps/bookmarks/templates/settings.php +++ b/apps/bookmarks/templates/settings.php @@ -8,7 +8,7 @@ ?>
- t('Bookmarklet:');?> t('Add page to ownCloud'); ?> + t('Bookmarklet:');?> t('Add page to ownCloud'); ?>
t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?>
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 2d5cdea4d74..eb82d0d02ad 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -18,7 +18,7 @@ var missing_field_totime = 't('To Time')) ?>'; var missing_field_startsbeforeends = 't('The event ends before it starts')) ?>'; var missing_field_dberror = 't('There was a database fail')) ?>'; - var totalurl = '/calendars'; + var totalurl = '/calendars'; $(document).ready(function() { t('Calendar CalDAV syncing address:');?> -
+
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 4c0dfad6177..e81597f23d6 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -1,5 +1,5 @@
diff --git a/apps/contacts/templates/part.contactphoto.php b/apps/contacts/templates/part.contactphoto.php index 7d7ab237561..9e3f5876cd1 100644 --- a/apps/contacts/templates/part.contactphoto.php +++ b/apps/contacts/templates/part.contactphoto.php @@ -3,7 +3,7 @@ $id = $_['id']; $wattr = isset($_['width'])?'width="'.$_['width'].'"':''; $hattr = isset($_['height'])?'height="'.$_['height'].'"':''; ?> - src="?id=&refresh=" /> + src="?id=&refresh=" /> diff --git a/apps/contacts/templates/part.cropphoto.php b/apps/contacts/templates/part.cropphoto.php index cb416f0e415..5faa4aa6ac6 100644 --- a/apps/contacts/templates/part.cropphoto.php +++ b/apps/contacts/templates/part.cropphoto.php @@ -38,13 +38,13 @@ OC_Log::write('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', return true; });*/ - + + action=""> diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php index c647e44c25b..8673e4521d9 100644 --- a/apps/contacts/templates/settings.php +++ b/apps/contacts/templates/settings.php @@ -2,6 +2,6 @@
t('Contacts'); ?>
t('CardDAV syncing address:'); ?> -
+
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index 138b65d1fd7..97c09308607 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -207,7 +207,7 @@ class OC_MEDIA_AMPACHE{ echo("\t\t$name\n"); echo("\t\t$artistName\n"); echo("\t\t$albumName\n"); - $url=OC_Helper::linkTo('media', 'server/xml.server.php', null, true)."?action=play&song=$id&auth={$_GET['auth']}"; + $url=OC_Helper::linkToAbsolute('media', 'server/xml.server.php')."?action=play&song=$id&auth={$_GET['auth']}"; $url=self::fixXmlString($url); echo("\t\t$url\n"); echo("\t\t\n"); diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php index ac813c20850..2907c616cf6 100644 --- a/apps/media/templates/settings.php +++ b/apps/media/templates/settings.php @@ -2,6 +2,6 @@
Media
Ampache address: -
+
diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 912019a9700..cbcbe544221 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -14,8 +14,8 @@ if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'=')) } } -OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$userName)); -OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$userName)); +OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); +OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); OC_APP::registerPersonal('user_openid','settings'); diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index a267e020507..8fec713aa71 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -43,7 +43,7 @@ if(!OC_User::userExists($USERNAME)){ OC_Log::write('user_openid',$USERNAME.' doesn\'t exist',OC_Log::WARN); $USERNAME=''; } -$IDENTITY=OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$USERNAME; +$IDENTITY=OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$USERNAME; require_once 'phpmyid.php'; diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index ede94dab2d7..30caa2d23da 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -16,7 +16,7 @@ if (isset($_POST['user'])) { OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token); $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; + $link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php').'?user='.$_POST['user'].'&token='.$token; $tmpl = new OC_Template('core/lostpassword', 'email'); $tmpl->assign('link', $link); $msg = $tmpl->fetchPage(); diff --git a/index.php b/index.php index 9bd460be353..18ea3022bc5 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if($not_installed) { // Handle WebDAV if($_SERVER['REQUEST_METHOD']=='PROPFIND'){ - header('location: '.OC_Helper::linkTo('files','webdav.php')); + header('location: '.OC_Helper::linkToAbsolute('files','webdav.php')); exit(); } diff --git a/lib/helper.php b/lib/helper.php index 6d3df6d97e7..b1e6d053a19 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -54,12 +54,6 @@ class OC_Helper { } } - if($absolute){ - // 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; - } - if($redirect_url) return $urlLinkTo.'?redirect_url='.urlencode($_SERVER["REQUEST_URI"]); else @@ -67,6 +61,23 @@ class OC_Helper { } + /** + * @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 ); + // 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; + return $urlLinkTo; + } + /** * @brief Creates path to an image * @param $app app diff --git a/lib/util.php b/lib/util.php index 43fb4413f04..4ba04fff3e8 100644 --- a/lib/util.php +++ b/lib/util.php @@ -248,7 +248,7 @@ class OC_Util { */ public static function checkAppEnabled($app){ if( !OC_App::isEnabled($app)){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } @@ -259,7 +259,7 @@ class OC_Util { public static function checkLoggedIn(){ // Check if we are a user if( !OC_User::isLoggedIn()){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } @@ -271,7 +271,7 @@ class OC_Util { // Check if we are a user self::checkLoggedIn(); if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ - header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } } diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 80d2cb0a86f..57731d979d9 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -41,7 +41,7 @@

WebDAV -
+
t('use this address to connect to your ownCloud in your file manager');?>

From e8b69d45a3afd9633b997eb178e159f9f97f4766 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 16 Feb 2012 19:48:20 +0100 Subject: [PATCH 05/70] Fixup use of OC_Helper::linkTo function --- apps/calendar/lib/search.php | 2 +- apps/contacts/lib/search.php | 2 +- apps/gallery/appinfo/app.php | 2 +- apps/media/lib_media.php | 6 +++--- files/index.php | 6 +++--- lib/app.php | 2 +- lib/search/provider/file.php | 10 +++++----- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 425c93c7338..0016751a66a 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -36,7 +36,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i'); } - $link = OC_Helper::linkTo('apps/calendar', 'index.php?showevent='.urlencode($object['id'])); + $link = OC_Helper::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']); $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type } } diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php index 97638821007..5aad6a25f09 100644 --- a/apps/contacts/lib/search.php +++ b/apps/contacts/lib/search.php @@ -18,7 +18,7 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{ $vcards = OC_Contacts_VCard::all($addressbook['id']); foreach($vcards as $vcard){ if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){ - $link = OC_Helper::linkTo('apps/contacts', 'index.php?id='.urlencode($vcard['id'])); + $link = OC_Helper::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']); $results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type } } diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index da872274497..b8de32ea587 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -46,7 +46,7 @@ OC_App::addNavigationEntry( array( $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%')); $results=array(); while($row=$result->fetchRow()){ - $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo('apps/gallery', 'index.php?view='.$row['album_name']),'Galleries'); + $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo('gallery', 'index.php').'?view='.$row['album_name'],'Galleries'); } return $results; } diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 0ade0e593dc..1bcd0f08c80 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -89,18 +89,18 @@ class OC_MediaSearchProvider extends OC_Search_Provider{ $songs=OC_MEDIA_COLLECTION::getSongs(0,0,$query); $results=array(); foreach($artists as $artist){ - $results[]=new OC_Search_Result($artist['artist_name'],'',OC_Helper::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist['artist_name']) ),'Music'); + $results[]=new OC_Search_Result($artist['artist_name'],'',OC_Helper::linkTo( 'media', 'index.php').'#artist='.urlencode($artist['artist_name']),'Music'); } foreach($albums as $album){ $artist=OC_MEDIA_COLLECTION::getArtistName($album['album_artist']); - $results[]=new OC_Search_Result($album['album_name'],'by '.$artist,OC_Helper::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist).'&album='.urlencode($album['album_name']) ),'Music'); + $results[]=new OC_Search_Result($album['album_name'],'by '.$artist,OC_Helper::linkTo( 'media', 'index.php').'#artist='.urlencode($artist).'&album='.urlencode($album['album_name']),'Music'); } foreach($songs as $song){ $minutes=floor($song['song_length']/60); $secconds=$song['song_length']%60; $artist=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']); $album=OC_MEDIA_COLLECTION::getalbumName($song['song_album']); - $results[]=new OC_Search_Result($song['song_name'],"by $artist, in $album $minutes:$secconds",OC_Helper::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist).'&album='.urlencode($album).'&song='.urlencode($song['song_name']) ),'Music'); + $results[]=new OC_Search_Result($song['song_name'],"by $artist, in $album $minutes:$secconds",OC_Helper::linkTo( 'media', 'index.php').'#artist='.urlencode($artist).'&album='.urlencode($album).'&song='.urlencode($song['song_name']),'Music'); } return $results; } diff --git a/files/index.php b/files/index.php index f166790ba9c..a29d3fb7e1e 100644 --- a/files/index.php +++ b/files/index.php @@ -76,11 +76,11 @@ foreach( explode( "/", $dir ) as $i ){ // make breadcrumb und filelist markup $list = new OC_Template( "files", "part.list", "" ); $list->assign( "files", $files ); -$list->assign( "baseURL", OC_Helper::linkTo("files", "index.php?dir=")); -$list->assign( "downloadURL", OC_Helper::linkTo("files", "download.php?file=")); +$list->assign( "baseURL", OC_Helper::linkTo("files", "index.php")."?dir="); +$list->assign( "downloadURL", OC_Helper::linkTo("files", "download.php")."?file="); $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" ); $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); -$breadcrumbNav->assign( "baseURL", OC_Helper::linkTo("files", "index.php?dir=")); +$breadcrumbNav->assign( "baseURL", OC_Helper::linkTo("files", "index.php")."?dir="); $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); diff --git a/lib/app.php b/lib/app.php index 22d18b17eec..1879a89cee3 100644 --- a/lib/app.php +++ b/lib/app.php @@ -230,7 +230,7 @@ class OC_App{ // admin users menu $settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "settings", "users.php" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" )); // 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" )); + $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( "settings", "log.svg" )); diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php index c3dc2942aef..34803c75aeb 100644 --- a/lib/search/provider/file.php +++ b/lib/search/provider/file.php @@ -7,7 +7,7 @@ class OC_Search_Provider_File extends OC_Search_Provider{ foreach($files as $fileData){ $file=$fileData['path']; if($fileData['mime']=='httpd/unix-directory'){ - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php?dir='.$file ),'Files'); + $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php' ).'?dir='.$file,'Files'); }else{ $mime=$fileData['mime']; $mimeBase=$fileData['mimepart']; @@ -15,16 +15,16 @@ class OC_Search_Provider_File extends OC_Search_Provider{ case 'audio': break; case 'text': - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Text'); + $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Text'); break; case 'image': - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Images'); + $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Images'); break; default: if($mime=='application/xml'){ - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Text'); + $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Text'); }else{ - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Files'); + $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Files'); } } } From dab553147470a78dfbe0f220908e35f639d956f6 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 16 Feb 2012 21:01:13 +0100 Subject: [PATCH 06/70] Bookmarks: Fix image urls in bookmarks.js --- apps/bookmarks/js/bookmarks.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index 77f767cdb81..fadbbd5513a 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -85,7 +85,14 @@ function addOrEditBookmark(event) { $('.bookmarks_add').children('p').children('.bookmarks_input').val(''); $('.bookmarks_list').prepend( '
' + - '

 

' + + '

' + + '' + + '' + + ' ' + + '' + + '' + + '' + + '

' + '

' + title + '

' + '

' + tagshtml + '

' + '

' + url + '

' + @@ -154,8 +161,17 @@ function updateBookmarksList(bookmark) { } $('.bookmarks_list').append( '
' + - '

 

' + - '

' + encodeEntities(bookmark.title) + '

' + + '

' + + '' + + '' + + ' ' + + '' + + '' + + '' + + '

' + + '

'+ + '' + encodeEntities(bookmark.title) + '' + + '

' + '

' + encodeEntities(bookmark.url) + '

' + '
' ); From a33b757b192384e612f278feeb30d998b3816a4d Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:36:55 +0100 Subject: [PATCH 07/70] Calendar: Add default repeat values when editing a non-repeating event --- apps/calendar/ajax/editeventform.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index 9ae3ffa8d94..19f6a80a167 100644 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php @@ -243,6 +243,16 @@ if($repeat['repeat'] != 'doesnotrepeat'){ $tmpl->assign('repeat_bymonth', $repeat['bymonth']); $tmpl->assign('repeat_byweekno', $repeat['byweekno']); } +else { + $tmpl->assign('repeat_month', 'monthday'); + $tmpl->assign('repeat_weekdays', array()); + $tmpl->assign('repeat_interval', 1); + $tmpl->assign('repeat_end', 'never'); + $tmpl->assign('repeat_count', '10'); + $tmpl->assign('repeat_weekofmonth', 'auto'); + $tmpl->assign('repeat_date', ''); + $tmpl->assign('repeat_year', 'bydate'); +} $tmpl->printpage(); -?> \ No newline at end of file +?> From 539fd7240c463d71ea885ca1c2a1eb292a7cceac Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:39:54 +0100 Subject: [PATCH 08/70] Calendar: optimize sending calendar events, also enabled caching of result --- apps/calendar/ajax/events.php | 30 +++++++++++++++++++----------- apps/calendar/lib/calendar.php | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index dd593ddec99..7734129bd95 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -9,7 +9,8 @@ require_once ('../../../lib/base.php'); require_once('../../../3rdparty/when/When.php'); -function addoutput($event, $vevent, $return_event){ +function create_return_event($event, $vevent){ + $return_event = array(); $return_event['id'] = (int)$event['id']; $return_event['title'] = htmlspecialchars($event['summary']); $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):''; @@ -29,15 +30,21 @@ OC_JSON::checkAppEnabled('calendar'); $start = DateTime::createFromFormat('U', $_GET['start']); $end = DateTime::createFromFormat('U', $_GET['end']); +$calendar = OC_Calendar_App::getCalendar($_GET['calendar_id']); +OC_Response::enableCaching(0); +OC_Response::setETagHeader($calendar['ctag']); + $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; + + $return_event = create_return_event($event, $vevent); + $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); - $return_event = array(); $start_dt = $dtstart->getDateTime(); $end_dt = $dtend->getDateTime(); if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ @@ -47,13 +54,17 @@ foreach($events as $event){ $start_dt->setTimezone(new DateTimeZone($user_timezone)); $end_dt->setTimezone(new DateTimeZone($user_timezone)); } + //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); + $r->recur($start_dt)->rrule((string) $vevent->RRULE); while($result = $r->next()){ - if($result->format('U') > $_GET['end']){ + if($result < $start){ + continue; + } + if($result > $end){ break; } if($return_event['allDay'] == true){ @@ -63,22 +74,19 @@ foreach($events as $event){ $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); + $return[] = $return_event; } }else{ - $return_event = array(); - if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ - $return_event['allDay'] = true; + if($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); + $return[] = $return_event; } } OC_JSON::encodedPrint($return); -?> \ No newline at end of file +?> diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 5e272991f20..679649582d8 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -246,6 +246,7 @@ class OC_Calendar_Calendar{ 'backgroundColor' => '#'.$calendar['calendarcolor'], 'borderColor' => '#888', 'textColor' => 'black', + 'cache' => true, ); } } From 6bbd67c3c693ab3cc440be7342b3cc8b88806a18 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:40:57 +0100 Subject: [PATCH 09/70] Calendar: only update default view when it really changed --- apps/calendar/js/calendar.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 6f1f52eafa1..517d2ce128b 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -689,7 +689,10 @@ $(document).ready(function(){ allDayText: allDayText, viewDisplay: function(view) { $('#datecontrol_date').html(view.title); - $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name); + if (view.name != defaultView) { + $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name); + defaultView = view.name; + } Calendar.UI.setViewActive(view.name); if (view.name == 'agendaWeek') { $('#calendar_holder').fullCalendar('option', 'aspectRatio', 0.1); From bd7227bb934c6d618c46eb818c8ce0f6ecb64e29 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:42:56 +0100 Subject: [PATCH 10/70] Spelling fix hint text --- lib/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config.php b/lib/config.php index 8d03271b3ea..ad1cd18fa15 100644 --- a/lib/config.php +++ b/lib/config.php @@ -174,7 +174,7 @@ class OC_Config{ $result=@file_put_contents( OC::$SERVERROOT."/config/config.php", $content ); if(!$result) { $tmpl = new OC_Template( '', 'error', 'guest' ); - $tmpl->assign('errors',array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver use write access to the config directory in owncloud"))); + $tmpl->assign('errors',array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); $tmpl->printPage(); exit; } From 45cff7b7378ff351158d9d93b879dcfc156171aa Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:59:43 +0100 Subject: [PATCH 11/70] Move storing "last updated at" time to the app config This way the config.php file is not changed every time you go to the personal page. Step to make it possible to have a read-only config.php most of the time --- lib/setup.php | 5 +++-- lib/updater.php | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index eb32e84713f..3e46a3dcc9a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -77,8 +77,6 @@ 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']; @@ -224,6 +222,9 @@ class OC_Setup { } if(count($error) == 0) { + OC_Appconfig::setValue('core', 'installedat',microtime(true)); + OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true)); + //create the user and group OC_User::createUser($username, $password); OC_Group::createGroup('admin'); diff --git a/lib/updater.php b/lib/updater.php index cc4a4602539..57623797ae5 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -29,12 +29,12 @@ class OC_Updater{ * Check if a new version is available */ public static function check(){ - OC_Config::setValue('lastupdatedat',microtime(true)); + OC_Appconfig::setValue('core', '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['installed']=OC_Config::getValue('installedat'); + $version['updated']=OC_Appconfig::getValue('core', 'lastupdatedat', OC_Config::getValue( 'lastupdatedat')); $version['updatechannel']='stable'; $versionstring=implode('x',$version); From 1fa05894d51235a46cf67812227d5e8363f87d54 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 22:01:53 +0100 Subject: [PATCH 12/70] Move config.php writable test to update path This should make it possible to use owncloud with a read-only config.php --- lib/base.php | 7 +++++++ lib/util.php | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index 8f169a5732f..880645ff79d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -171,6 +171,13 @@ class OC{ echo 'Error while upgrading the database'; die(); } + if(file_exists(OC::$SERVERROOT."/config/config.php") and !is_writable(OC::$SERVERROOT."/config/config.php")) { + $tmpl = new OC_Template( '', 'error', 'guest' ); + $tmpl->assign('errors',array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); + $tmpl->printPage(); + exit; + } + OC_Config::setValue('version',implode('.',OC_Util::getVersion())); } diff --git a/lib/util.php b/lib/util.php index 4ba04fff3e8..ee32d31bfd0 100644 --- a/lib/util.php +++ b/lib/util.php @@ -226,10 +226,6 @@ class OC_Util { $errors[]=array('error'=>'PHP module ctype is not installed.
','hint'=>'Please ask your server administrator to install the module.'); } - if(file_exists(OC::$SERVERROOT."/config/config.php") and !is_writable(OC::$SERVERROOT."/config/config.php")){ - $errors[]=array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver use write access to the config directory in owncloud"); - } - return $errors; } From 6f1ed85f0b6a7e675951a587f1308211b698a6d5 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 17 Feb 2012 21:56:20 -0500 Subject: [PATCH 13/70] Temporary fix for sharing files --- apps/files_sharing/lib_share.php | 15 +++++---- lib/filestorage/google.php | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 lib/filestorage/google.php diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index 049a74278b3..42739bdfba9 100644 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -88,12 +88,15 @@ class OC_Share { $uid = $uid."@".$gid; } $query->execute(array($uid_owner, $uid, $source, $target, $permissions)); - // Clear the folder size cache for the 'Shared' folder -// $clearFolderSize = OC_DB::prepare("DELETE FROM *PREFIX*foldersize WHERE path = ?"); -// $clearFolderSize->execute(array($sharedFolder)); - // Emit post_create and post_write hooks to notify of a new file in the user's filesystem - OC_Hook::emit("OC_Filesystem", "post_create", array('path' => $target)); - OC_Hook::emit("OC_Filesystem", "post_write", array('path' => $target)); + // Add file to filesystem cache + $userDirectory = "/".OC_User::getUser()."/files"; + $data = OC_Filecache::get(substr($source, strlen($userDirectory))); + $parentQuery = OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); + $parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow(); + $parent = $parentResult['id']; + $is_writeable = $permissions & OC_Share::WRITE; + $cacheQuery = OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)'); + $cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable)); } } } diff --git a/lib/filestorage/google.php b/lib/filestorage/google.php new file mode 100644 index 00000000000..fc271f4e4ba --- /dev/null +++ b/lib/filestorage/google.php @@ -0,0 +1,55 @@ +. +*/ + +class OC_Filestorage_Google extends OC_Filestorage_Common { + + private $auth; + + public function __construct($parameters) { + + } + + private function connect() { + + } + public function mkdir($path){} + public function rmdir($path){} + public function opendir($path){} + public function is_dir($path){} + public function is_file($path){} + public function stat($path){} + public function filetype($path){} + public function is_readable($path){} + public function is_writable($path){} + public function file_exists($path){} + public function unlink($path){} + public function rename($path1,$path2){} + public function fopen($path,$mode){} + public function toTmpFile($path){} + public function fromTmpFile($tmpPath,$path){} + public function fromUploadedFile($tmpPath,$path){} + public function getMimeType($path){} + public function hash($type,$path,$raw){} + public function free_space($path){} + public function search($query){} + public function getLocalFile($path){} +} \ No newline at end of file From 71aa36c3f16942cd35f550253b892f5be4116784 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 16 Feb 2012 23:24:23 +0100 Subject: [PATCH 14/70] ETags must be quoted. --- lib/response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/response.php b/lib/response.php index 9edae3603b2..a75135c0176 100644 --- a/lib/response.php +++ b/lib/response.php @@ -116,7 +116,7 @@ class OC_Response { self::setStatus(self::STATUS_NOT_MODIFIED); exit; } - header('ETag: '.$etag); + header('ETag: "'.$etag.'"'); } /** From 96612c506e08ce6b2fb39425c73f0a8d81a4cad8 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 17 Feb 2012 09:35:18 +0100 Subject: [PATCH 15/70] Removed obsolete commented code and made minor speed improvements. Added stub function for loading categories. --- apps/contacts/js/contacts.js | 63 +++++++----------------- apps/contacts/templates/part.contact.php | 53 -------------------- 2 files changed, 17 insertions(+), 99 deletions(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 30793625746..c9d1dc30f03 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -117,7 +117,7 @@ Contacts={ $('#carddav_url_close').show(); }, messageBox:function(title, msg) { - if(msg.toLowerCase().indexOf('auth') > 0) { + if(msg.toLowerCase().indexOf('auth') != -1) { // fugly hack, I know alert(msg); } @@ -335,17 +335,6 @@ Contacts={ // Load first in list. if($('#contacts li').length > 0) { Contacts.UI.Card.update(); - /* - var firstid = $('#contacts li:first-child').data('id'); - console.log('trying to load: ' + firstid); - $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':firstid},function(jsondata){ - if(jsondata.status == 'success'){ - Contacts.UI.Card.loadContact(jsondata.data); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - } - });*/ } else { // load intro page $.getJSON('ajax/loadintro.php',{},function(jsondata){ @@ -374,6 +363,7 @@ Contacts={ $('#rightcontent').data('id',this.id); //console.log('loaded: ' + this.data.FN[0]['value']); this.populateNameFields(); + this.loadCategories(); this.loadPhoto(); this.loadMails(); this.loadPhones(); @@ -455,9 +445,6 @@ Contacts={ this.fullname += ', ' + this.honsuf; } $('#n').html(this.fullname); - //$('.jecEditableOption').attr('title', 'Custom'); - //$('.jecEditableOption').text(this.fn); - //$('.jecEditableOption').attr('value', 0); $('#fn_select option').remove(); $('#fn_select').combobox('value', this.fn); var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname]; @@ -466,17 +453,16 @@ Contacts={ .append($('') .text(value)); }); - /*$('#full').text(this.fullname); - $('#short').text(this.givname + ' ' + this.famname); - $('#reverse').text(this.famname + ' ' + this.givname); - $('#reverse_comma').text(this.famname + ', ' + this.givname);*/ $('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']); $('#contact_identity').find('*[data-element="FN"]').data('checksum', this.data.FN[0]['checksum']); $('#contact_identity').show(); }, + loadCategories:function(){ + if(this.data.CATEGORIES) { + // + } + }, editNew:function(){ // add a new contact - //Contacts.UI.notImplemented(); - //return false; this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; $.getJSON('ajax/newcontact.php',{},function(jsondata){ if(jsondata.status == 'success'){ @@ -713,12 +699,6 @@ Contacts={ .text(value)); }); - /*$('#short').text(n[1] + ' ' + n[0]); - $('#full').text(this.fullname); - $('#reverse').text(n[0] + ' ' + n[1]); - $('#reverse_comma').text(n[0] + ', ' + n[1]);*/ - //$('#n').html(full); - //$('#fn').val(0); if(this.id == '') { var aid = $(dlg).find('#aid').val(); Contacts.UI.Card.add(n.join(';'), $('#short').text(), aid); @@ -889,21 +869,22 @@ Contacts={ }, loadPhoto:function(){ if(this.data.PHOTO) { + $.getJSON('ajax/loadphoto.php',{'id':this.id},function(jsondata){ + if(jsondata.status == 'success'){ + //alert(jsondata.data.page); + $('#contacts_details_photo_wrapper').html(jsondata.data.page); + } + else{ + Contacts.UI.messageBox(jsondata.data.message); + } + }); $('#file_upload_form').show(); $('#contacts_propertymenu a[data-type="PHOTO"]').parent().hide(); } else { + $('#contacts_details_photo_wrapper').empty(); $('#file_upload_form').hide(); $('#contacts_propertymenu a[data-type="PHOTO"]').parent().show(); } - $.getJSON('ajax/loadphoto.php',{'id':this.id},function(jsondata){ - if(jsondata.status == 'success'){ - //alert(jsondata.data.page); - $('#contacts_details_photo_wrapper').html(jsondata.data.page); - } - else{ - Contacts.UI.messageBox(jsondata.data.message); - } - }); }, editPhoto:function(id, tmp_path){ //alert('editPhoto: ' + tmp_path); @@ -1143,13 +1124,6 @@ $(document).ready(function(){ return false; }); - /** - * Open blank form to add new contact. - * FIXME: Load the same page but only show name data and popup the name edit dialog. - * On save load the page again with an id and show all fields. - * NOTE: Or: Load the full page and popup name dialog modal. On success set the newly aquired ID, on - * Cancel or failure give appropriate message and show ... something else :-P - */ $('#contacts_newcontact').click(function(){ Contacts.UI.Card.editNew(); }); @@ -1175,9 +1149,6 @@ $(document).ready(function(){ return false; }); - /** - * Delete currently selected contact TODO: and clear page - */ $('#contacts_deletecard').live('click',function(){ Contacts.UI.Card.delete(); }); diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index 408b595dc95..5be20964f4b 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -70,14 +70,6 @@ $id = isset($_['id']) ? $_['id'] : ''; - -
  • - /> - -
  • -
    @@ -93,17 +85,6 @@ $id = isset($_['id']) ? $_['id'] : ''; - -
  • - /> - - -
  • -
    @@ -118,40 +99,6 @@ $id = isset($_['id']) ? $_['id'] : '';
      - -
      -
      - - - - 0) { - //array_walk($address['parameters'], ) Nah, this wont work... - $translated = array(); - foreach($address['parameters'] as $type) { - $translated[] = $l->t(ucwords(strtolower($type))); - } - echo implode('/', $translated); - } - ?> -
      -
      -
        - '.$adr[0].'':''); - $tmp .= ($adr[1]?'
      • '.$adr[1].'
      • ':''); - $tmp .= ($adr[2]?'
      • '.$adr[2].'
      • ':''); - $tmp .= ($adr[3]||$adr[5]?'
      • '.$adr[5].' '.$adr[3].'
      • ':''); - $tmp .= ($adr[4]?'
      • '.$adr[4].'
      • ':''); - $tmp .= ($adr[6]?'
      • '.$adr[6].'
      • ':''); - echo $tmp; - - ?> -
      -
      -
      - From 868cf6bb836c136d2ad881bf99710404c74507c3 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 17 Feb 2012 19:04:12 +0100 Subject: [PATCH 16/70] Avoid errors from missing GD library. --- apps/contacts/photo.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 8dfbcb6fb10..298f1215e3c 100644 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -13,10 +13,19 @@ require_once('../../lib/base.php'); OC_Util::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); +function getStandardImage(){ + OC_Response::setExpiresHeader('P10D'); + OC_Response::enableCaching(); + OC_Response::redirect(OC_Helper::imagePath('contacts', 'person_large.png')); +} + $id = $_GET['id']; $contact = OC_Contacts_App::getContactVCard($id); $image = new OC_Image(); +if(!$image) { + getStandardImage(); +} // invalid vcard if( is_null($contact)) { OC_Log::write('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR); @@ -45,7 +54,8 @@ if( is_null($contact)) { } if (!$image->valid()) { // Not found :-( - $image->loadFromFile('img/person_large.png'); + getStandardImage(); + //$image->loadFromFile('img/person_large.png'); } header('Content-Type: '.$image->mimeType()); $image->show(); From 2ee2f87efee630d9f85c8fe11c783901c469addf Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 18 Feb 2012 11:42:58 +0100 Subject: [PATCH 17/70] Strip tags on address on client side. --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index c9d1dc30f03..d33f983a429 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -815,7 +815,7 @@ Contacts={ checksum = Contacts.UI.checksumFor(obj); container = Contacts.UI.propertyContainerFor(obj); } - var adr = new Array($(dlg).find('#adr_pobox').val(),$(dlg).find('#adr_extended').val(),$(dlg).find('#adr_street').val(),$(dlg).find('#adr_city').val(),$(dlg).find('#adr_region').val(),$(dlg).find('#adr_zipcode').val(),$(dlg).find('#adr_country').val()); + var adr = new Array($(dlg).find('#adr_pobox').val().strip_tags(),$(dlg).find('#adr_extended').val().strip_tags(),$(dlg).find('#adr_street').val().strip_tags(),$(dlg).find('#adr_city').val().strip_tags(),$(dlg).find('#adr_region').val().strip_tags(),$(dlg).find('#adr_zipcode').val().strip_tags(),$(dlg).find('#adr_country').val().strip_tags()); $(container).find('.adr').val(adr.join(';')); $(container).find('.adr_type').val($(dlg).find('#adr_type').val()); $(container).find('.adr_type_label').html(t('contacts',ucwords($(dlg).find('#adr_type').val().toLowerCase()))); From 71a2241aee6f5f372b43fe977e494fea8a98d9cd Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 18 Feb 2012 23:53:10 +0000 Subject: [PATCH 18/70] Fixed call to OC_User. Thanks Burillo on IRC --- apps/contacts/lib/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 016bd2b791a..ff348403a9b 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -53,7 +53,7 @@ class OC_Contacts_App { OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR); } else { - OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.$OC_User::getUser(), OC_Log::ERROR); + OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OC_Log::ERROR); } OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved? exit(); From 87627c7a503f10875d8fa0171624b6e586d1cc7b Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 18 Feb 2012 19:30:35 -0500 Subject: [PATCH 19/70] Fix overwriting of internal sharing for shared folders - bug oc-260 --- apps/files_sharing/ajax/getitem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index 51fda6aed40..ba01adffb9a 100644 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -8,6 +8,7 @@ require_once('../lib_share.php'); $userDirectory = "/".OC_User::getUser()."/files"; $source = $userDirectory.$_GET['source']; $path = $source; +$users = array(); if ($users = OC_Share::getMySharedItem($source)) { for ($i = 0; $i < count($users); $i++) { if ($users[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { @@ -19,7 +20,6 @@ $source = dirname($source); while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) { if ($values = OC_Share::getMySharedItem($source)) { $values = array_values($values); - $users = array(); $parentUsers = array(); for ($i = 0; $i < count($values); $i++) { if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) { From 9d2379742b92b223dd2cc171e6a155533cabc889 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 19 Feb 2012 21:24:53 +0100 Subject: [PATCH 20/70] apps/calendar: update ctag after deleteFromDAVData Without this clients won't see the update because they compare ctags before fetching the actual calendar to reduce traffic. Signed-off-by: Florian Pritz --- apps/calendar/lib/object.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index cbb1badf802..230c610d35a 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -194,6 +194,7 @@ class OC_Calendar_Object{ public static function deleteFromDAVData($cid,$uri){ $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); $stmt->execute(array($cid,$uri)); + OC_Calendar_Calendar::touchCalendar($cid); return true; } From 490c9db15da89797eea5c3e30fc9a0790bd60b32 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Sun, 19 Feb 2012 20:18:27 -0500 Subject: [PATCH 21/70] Added bookmarklet for browser. Inspired by Google Bookmarks --- apps/bookmarks/addBm.php | 3 ++- apps/bookmarks/css/bookmarks.css | 15 ++++++++++++++- apps/bookmarks/templates/list.php | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php index 62ad5821dbf..f56022c42c2 100644 --- a/apps/bookmarks/addBm.php +++ b/apps/bookmarks/addBm.php @@ -40,6 +40,7 @@ $url = isset($_GET['url']) ? urldecode($_GET['url']) : ''; $metadata = getURLMetadata($url); $tmpl->assign('URL', htmlentities($metadata['url'],ENT_COMPAT,'utf-8')); -$tmpl->assign('TITLE', htmlentities($metadata['title'],ENT_COMPAT,'utf-8')); +$title = isset($metadata['title']) ? $metadata['title'] : (isset($_GET['title']) ? $_GET['title'] : ''); +$tmpl->assign('TITLE', htmlentities($title,ENT_COMPAT,'utf-8')); $tmpl->printPage(); diff --git a/apps/bookmarks/css/bookmarks.css b/apps/bookmarks/css/bookmarks.css index 48f0bede110..8dfdc8a07b9 100644 --- a/apps/bookmarks/css/bookmarks.css +++ b/apps/bookmarks/css/bookmarks.css @@ -83,4 +83,17 @@ .loading_meta { display: none; margin-left: 5px; -} \ No newline at end of file +} + +#footer { + color: #999; + font-size: medium; + text-align: center; + position: absolute; + bottom: 10px; + left: 0px; + width: 100%; + height: 20px; + visibility: visible; + display: block +} diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index ccfe74f008f..d44a0ecbcdb 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -22,4 +22,8 @@
      t('You have no bookmarks'); ?> -
      \ No newline at end of file + + From 7ff4e40b20dfeb937ff6dccbc87e42a8bc4f5115 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 16 Feb 2012 17:55:39 +0100 Subject: [PATCH 22/70] Combing LDAP backend with LDAP extended backend --- apps/user_ldap/appinfo/app.php | 6 +-- apps/user_ldap/templates/settings.php | 3 ++ apps/user_ldap/user_ldap.php | 78 +++++++++++++++++++++------ 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php index 3261708f590..5c56ca8191e 100644 --- a/apps/user_ldap/appinfo/app.php +++ b/apps/user_ldap/appinfo/app.php @@ -32,13 +32,13 @@ define('OC_USER_BACKEND_LDAP_DEFAULT_PORT', 389); define('OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME', 'uid'); // register user backend -OC_User::useBackend( "LDAP" ); +OC_User::useBackend( 'LDAP' ); // add settings page to navigation $entry = array( - 'id' => "user_ldap_settings", + 'id' => 'user_ldap_settings', 'order'=>1, - 'href' => OC_Helper::linkTo( "user_ldap", "settings.php" ), + 'href' => OC_Helper::linkTo( 'user_ldap', 'settings.php' ), 'name' => 'LDAP' ); // OC_App::addNavigationSubEntry( "core_users", $entry); diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 2abb0b47291..5bbd5d4008d 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -12,6 +12,9 @@ t('Currently the display name field needs to be the same you matched %%uid against in the filter above, because ownCloud doesn\'t distinguish between user id and user name.');?>

      >

      >

      +

      + bytes

      +

      diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 106240e74b8..670d938ea95 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -36,6 +36,12 @@ class OC_USER_LDAP extends OC_User_Backend { protected $ldap_tls; protected $ldap_nocase; protected $ldap_display_name; + protected $ldap_quota; + protected $ldap_quota_def; + protected $ldap_email; + + // will be retrieved from LDAP server + protected $ldap_dc = false; function __construct() { $this->ldap_host = OC_Appconfig::getValue('user_ldap', 'ldap_host',''); @@ -47,6 +53,9 @@ class OC_USER_LDAP extends OC_User_Backend { $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); + $this->ldap_quota_attr = OC_Appconfig::getValue('user_ldap', 'ldap_quota_attr',''); + $this->ldap_quota_def = OC_Appconfig::getValue('user_ldap', 'ldap_quota_def',''); + $this->ldap_email_attr = OC_Appconfig::getValue('user_ldap', 'ldap_email_attr',''); if( !empty($this->ldap_host) && !empty($this->ldap_port) @@ -66,6 +75,28 @@ class OC_USER_LDAP extends OC_User_Backend { ldap_unbind($this->ds); } + private function setQuota( $uid ) { + if( !$this->ldap_dc ) + return false; + + $quota = $this->ldap_dc[$this->ldap_quota_attr][0]; + $quota = $quota != -1 ? $quota : $this->ldap_quota_def; + OC_Preferences::setValue($uid, 'files', 'quota', $quota); + } + + private function setEmail( $uid ) { + if( !$this->ldap_dc ) + return false; + + $email = OC_Preferences::getValue($uid, 'settings', 'email', ''); + if ( !empty( $email ) ) + return false; + + $email = $this->ldap_dc[$this->ldap_email_attr][0]; + OC_Preferences::setValue($uid, 'settings', 'email', $email); + } + + //Connect to LDAP and store the resource private function getDs() { if(!$this->ds) { $this->ds = ldap_connect( $this->ldap_host, $this->ldap_port ); @@ -74,18 +105,19 @@ class OC_USER_LDAP extends OC_User_Backend { if($this->ldap_tls) ldap_start_tls($this->ds); } - + //TODO: Not necessary to perform a bind each time, is it? // login if(!empty($this->ldap_dn)) { $ldap_login = @ldap_bind( $this->ds, $this->ldap_dn, $this->ldap_password ); - if(!$ldap_login) + if(!$ldap_login) { return false; + } } return $this->ds; } - private function getDn( $uid ) { + private function getDc( $uid ) { if(!$this->configured) return false; @@ -99,31 +131,43 @@ class OC_USER_LDAP extends OC_User_Backend { $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; + } + + $this->ldap_dc = $entries[0]; - return $entries[0]['dn']; + return $this->ldap_dc; } public function checkPassword( $uid, $password ) { if(!$this->configured){ return false; } - $dn = $this->getDn( $uid ); - if( !$dn ) + $dc = $this->getDc( $uid ); + if( !$dc ) return false; - if (!@ldap_bind( $this->getDs(), $dn, $password )) + if (!@ldap_bind( $this->getDs(), $dc['dn'], $password )) { return false; - + } + + if(!empty($this->ldap_quota) && !empty($this->ldap_quota_def)) { + $this->setQuota($uid); + } + + if(!empty($this->ldap_email_attr)) { + $this->setEmail($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])) { + $ldap_display_name = strtolower($this->ldap_display_name); + if(isset($row[$ldap_display_name])) { return $row[$ldap_display_name][0]; } } @@ -131,12 +175,12 @@ class OC_USER_LDAP extends OC_User_Backend { else { return $uid; } - + } else { return $uid; } - + } public function userExists( $uid ) { @@ -146,17 +190,17 @@ 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 ); @@ -169,7 +213,7 @@ class OC_USER_LDAP extends OC_User_Backend { // 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]; + $users[] = $row[$ldap_display_name][0]; } } // TODO language specific sorting of user names From 30d524b4260fe3e920b6be1f3818a0fbcbb5adfc Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 20 Feb 2012 11:21:46 +0100 Subject: [PATCH 23/70] load apps before logout so that logout-hook works --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 18ea3022bc5..b4cac1879c6 100644 --- a/index.php +++ b/index.php @@ -51,6 +51,7 @@ if($_SERVER['REQUEST_METHOD']=='PROPFIND'){ // Someone is logged in : elseif(OC_User::isLoggedIn()) { if(isset($_GET["logout"]) and ($_GET["logout"])) { + OC_App::loadApps(); OC_User::logout(); header("Location: ".OC::$WEBROOT.'/'); exit(); @@ -80,7 +81,7 @@ else { OC_User::unsetMagicInCookie(); } } - + // Someone wants to log in : elseif(isset($_POST["user"]) && isset($_POST['password'])) { if(OC_User::login($_POST["user"], $_POST["password"])) { From 12bcbcdc62989bec8222888320aa22aeda06c82c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 19 Feb 2012 23:03:10 +0100 Subject: [PATCH 24/70] Update ctag in deleteFromDAVData. --- apps/contacts/lib/vcard.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index ece203bd458..17e95adff71 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -304,7 +304,7 @@ class OC_Contacts_VCard{ * @return boolean */ public static function delete($id){ - // FIXME: Add error checking. + // FIXME: Add error checking. Touch addressbook. $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt->execute(array($id)); @@ -329,6 +329,7 @@ class OC_Contacts_VCard{ // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt->execute(array($aid,$uri)); + OC_Contacts_Addressbook::touch($aid); return true; } From 456ada01fa44a5de3146f58ea5de60baffe31521 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 20 Feb 2012 14:36:21 +0100 Subject: [PATCH 25/70] Contacts: Apply strip_tags on compound values. --- apps/contacts/ajax/addproperty.php | 1 + apps/contacts/ajax/saveproperty.php | 1 + 2 files changed, 2 insertions(+) diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 03a45532f9b..028974e1c66 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -66,6 +66,7 @@ foreach($current as $item) { if(is_array($value)) { ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! + $value = array_map('strip_tags', $value); } else { $value = strip_tags($value); } diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 6c8132c1dbf..0c9e0cc7836 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -52,6 +52,7 @@ $checksum = isset($_POST['checksum'])?$_POST['checksum']:null; // } if(is_array($value)){ // FIXME: How to strip_tags for compound values? + $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); } else { From ffdfe8257bb89750352553e71e863843e2416925 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 20 Feb 2012 15:24:54 +0100 Subject: [PATCH 26/70] Contacts: Fix adding/updating address book with empty name. --- apps/contacts/ajax/createaddressbook.php | 8 +++++++- apps/contacts/ajax/updateaddressbook.php | 9 ++++++++- apps/contacts/js/contacts.js | 22 ++++++++++++++-------- apps/contacts/js/interface.js | 8 +++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index fbd70bae583..28944fe864c 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -13,7 +13,13 @@ OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); $userid = OC_User::getUser(); -$bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null); +$name = trim(strip_tags($_POST['name'])); +if(!$name) { + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); + OC_Log::write('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR); + exit(); +} +$bookid = OC_Contacts_Addressbook::add($userid, $name, null); if(!$bookid) { OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index b43b5b93a32..211df84b1d1 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -15,7 +15,14 @@ OC_JSON::checkAppEnabled('contacts'); $bookid = $_POST['id']; OC_Contacts_App::getAddressbook($bookid); // is owner access check -if(!OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null)) { +$name = trim(strip_tags($_POST['name'])); +if(!$name) { + OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); + OC_Log::write('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR); + exit(); +} + +if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); OC_Log::write('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OC_Log::ERROR); //exit(); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index d33f983a429..0e06b650a18 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1043,13 +1043,13 @@ Contacts={ return false; }else{ $.post(OC.filePath('contacts', 'ajax', 'deletebook.php'), { id: bookid}, - function(data) { - if (data.status == 'success'){ + function(jsondata) { + if (jsondata.status == 'success'){ $('#chooseaddressbook_dialog').dialog('destroy').remove(); Contacts.UI.Contacts.update(); Contacts.UI.Addressbooks.overview(); } else { - Contacts.UI.messageBox(t('contacts', 'Error'), data.message); + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); //alert('Error: ' + data.message); } }); @@ -1059,10 +1059,14 @@ Contacts={ Contacts.UI.notImplemented(); }, submit:function(button, bookid){ - var displayname = $("#displayname_"+bookid).val(); + var displayname = $("#displayname_"+bookid).val().trim(); var active = $("#edit_active_"+bookid+":checked").length; var description = $("#description_"+bookid).val(); - + + if(displayname.length == 0) { + Contacts.UI.messageBox(t('contacts', 'Error'), t('contacts', 'Displayname cannot be empty.')); + return false; + } var url; if (bookid == 'new'){ url = OC.filePath('contacts', 'ajax', 'createaddressbook.php'); @@ -1070,12 +1074,14 @@ Contacts={ url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php'); } $.post(url, { id: bookid, name: displayname, active: active, description: description }, - function(data){ - if(data.status == 'success'){ + function(jsondata){ + if(jsondata.status == 'success'){ $(button).closest('tr').prev().html(data.page).show().next().remove(); + Contacts.UI.Contacts.update(); + } else { + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); } }); - Contacts.UI.Contacts.update(); }, cancel:function(button, bookid){ $(button).closest('tr').prev().show().next().remove(); diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index fe58a46d247..5908dd767a2 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -124,12 +124,14 @@ Contacts={ url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php'); } $.post(url, { id: bookid, name: displayname, active: active, description: description }, - function(data){ - if(data.status == 'success'){ + function(jsondata){ + if(jsondata.status == 'success'){ $(button).closest('tr').prev().html(data.page).show().next().remove(); + Contacts.UI.Contacts.update(); + } else { + Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); } }); - Contacts.UI.Contacts.update(); }, cancel:function(button, bookid){ $(button).closest('tr').prev().show().next().remove(); From d5f7a39936616479d576b946514ef8cddf85f05b Mon Sep 17 00:00:00 2001 From: VicDeo Date: Mon, 20 Feb 2012 23:54:23 +0300 Subject: [PATCH 27/70] Contact list scroll fix --- apps/contacts/js/jquery.inview.js | 52 ++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/apps/contacts/js/jquery.inview.js b/apps/contacts/js/jquery.inview.js index a38ab164977..01900b0b4b4 100644 --- a/apps/contacts/js/jquery.inview.js +++ b/apps/contacts/js/jquery.inview.js @@ -5,18 +5,40 @@ */ (function ($) { var inviewObjects = {}, viewportSize, viewportOffset, - d = document, w = window, documentElement = d.documentElement, expando = $.expando; + d = document, w = window, documentElement = d.documentElement, expando = $.expando, isFiring = false, $elements = {}; $.event.special.inview = { add: function(data) { - inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) }; + var inviewObject = { data: data, $element: $(this) } + inviewObjects[data.guid + "-" + this[expando]] = inviewObject; + var selector = inviewObject.data.selector, + $element = inviewObject.$element; + var hash = parseInt(getHash( data.guid + this[expando])); + $elements[hash] = selector ? $element.find(selector) : $element; }, remove: function(data) { try { delete inviewObjects[data.guid + "-" + this[expando]]; } catch(e) {} + try { + var hash = parseInt(getHash(data.guid + this[expando])); + delete($elements[hash]); + } catch (e){} } }; + + function getHash(str){ + str = str+''; + var hash = 0; + if (str.length == 0) return hash; + for (i = 0; i < str.length; i++) { + char = str.charCodeAt(i); + hash = ((hash<<5)-hash)+char; + hash = hash & hash; // Convert to 32bit integer + } + return Math.abs(hash); + } + function getViewportSize() { var mode, domObject, size = { height: w.innerHeight, width: w.innerWidth }; @@ -46,22 +68,15 @@ } function checkInView() { - var $elements = $(), elementsLength, i = 0; - - $.each(inviewObjects, function(i, inviewObject) { - var selector = inviewObject.data.selector, - $element = inviewObject.$element; - $elements = $elements.add(selector ? $element.find(selector) : $element); - }); - - elementsLength = $elements.length; - if (elementsLength) { + if (isFiring){ + return; + } + isFiring = true; viewportSize = viewportSize || getViewportSize(); viewportOffset = viewportOffset || getViewportOffset(); - - for (; i Date: Mon, 20 Feb 2012 22:33:38 +0100 Subject: [PATCH 28/70] some icons for filetypes have been added. for licensing information please have look at core/img/filetypes/readme-2.txt --- ...ication-vnd.oasis.opendocument.formula.png | Bin 0 -> 580 bytes ...cation-vnd.oasis.opendocument.graphics.png | Bin 0 -> 572 bytes ...on-vnd.oasis.opendocument.presentation.png | Bin 0 -> 441 bytes ...ion-vnd.oasis.opendocument.spreadsheet.png | Bin 0 -> 436 bytes ...pplication-vnd.oasis.opendocument.text.png | Bin 0 -> 420 bytes .../filetypes/application-x-7z-compressed.png | Bin 0 -> 652 bytes .../application-x-bzip-compressed-tar.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-bzip.png | Bin 0 -> 652 bytes .../application-x-compressed-tar.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-deb.png | Bin 0 -> 652 bytes .../application-x-debian-package.png | Bin 0 -> 570 bytes core/img/filetypes/application-x-gzip.png | Bin 0 -> 652 bytes .../application-x-lzma-compressed-tar.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-rar.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-rpm.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-tar.png | Bin 0 -> 652 bytes core/img/filetypes/application-x-tarz.png | Bin 0 -> 652 bytes core/img/filetypes/application-zip.png | Bin 0 -> 652 bytes core/img/filetypes/readme-2.txt | 28 ++++++++++++++++++ 19 files changed, 28 insertions(+) create mode 100644 core/img/filetypes/application-vnd.oasis.opendocument.formula.png create mode 100644 core/img/filetypes/application-vnd.oasis.opendocument.graphics.png create mode 100644 core/img/filetypes/application-vnd.oasis.opendocument.presentation.png create mode 100644 core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png create mode 100644 core/img/filetypes/application-vnd.oasis.opendocument.text.png create mode 100644 core/img/filetypes/application-x-7z-compressed.png create mode 100644 core/img/filetypes/application-x-bzip-compressed-tar.png create mode 100644 core/img/filetypes/application-x-bzip.png create mode 100644 core/img/filetypes/application-x-compressed-tar.png create mode 100644 core/img/filetypes/application-x-deb.png create mode 100644 core/img/filetypes/application-x-debian-package.png create mode 100644 core/img/filetypes/application-x-gzip.png create mode 100644 core/img/filetypes/application-x-lzma-compressed-tar.png create mode 100644 core/img/filetypes/application-x-rar.png create mode 100644 core/img/filetypes/application-x-rpm.png create mode 100644 core/img/filetypes/application-x-tar.png create mode 100644 core/img/filetypes/application-x-tarz.png create mode 100644 core/img/filetypes/application-zip.png create mode 100644 core/img/filetypes/readme-2.txt diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.formula.png b/core/img/filetypes/application-vnd.oasis.opendocument.formula.png new file mode 100644 index 0000000000000000000000000000000000000000..4cefbb690d106f7858203f619cc7766aca4b7c19 GIT binary patch literal 580 zcmV-K0=xZ*P)bm%j6^(8~rQBta#G zP$H2;*<>xERs(;_oO}1~oTsbJON)3ppU?T8htp)5CIInxoS~ti6b+=5!r^dy z86F;vWwY7!>Vb$H6%mh!c#_HFH`zn!bXw--=0rqfbaXTo3!$ ze4cF-g7vcyiA4Nb>zQCM7y#A{fHUo_tQK{{#+C!keEPbGZQB404i5U2QZpkXBLTy0 zS+o>OG!@GY0Y@-!TNdSV84${nVNpj;X?;G>1m^|wZ+fu zA3{A{^!IfGptYtskw}n8B=GrsD5a|L`unhj35R-cIt|92O;ECJu6AA|GH|QTUk9j70C3{?F?zcK0vIK&fQ&{N)=iUpPl+;5-2DWk}@P)aN*wXo^!rG_xe()6ab5hizE_> zJUyV4!teLLOD2=?&CShn>q10^L}WxnMl8!(mo6w23X;p^L_{Q$$>a^g2#N^da2P#! zeeL_-JRx|y)~g80haeh_PI#WTY8XZYDC+=Ill%Bl^?C{i`!(LYFHx`80f@z76H2Mo zbUGc;gS8ri)!+E4Zcl>&bb_@SuInNq)a!NT=H@0G$GPVV%s-T#$_`{tD0X&sTIY?8 zjcr6EEF#k)GHqGbr*1=RLMhd@QmIs42MSHcVzF2Sc=_rzkDk83b{vKV2RIWw#rW7L znx?f?%$Ylwj0m(Z zRjimwdlPdUN@J=C6n(eDIrlj)@3|2X;Xl%VF<_{VSp~cUs!%9=1L7N}&;4$D%gv4h zFFzeHGd;m;%ME=vIy}I6txk|rE#7W3+EPSXPADLOM!emoTrQt9n@u~BNO---Nam>T z6h98;dg@ZCbcu*eRVtMm`GbnZqNxE_^?JP(w)O7eiS>;wug>SPq>_^WxULH#f?*h@ zh{*O{K{AW0-iF)z$DUe5B(u0GxA%`CB4QYZiHM-od@kDyU0?AWDWy69%d&o1_e1=d_+?pE2heCV jNT<`+p_CBCVlln|C&Vf^)P;a%00000NkvXXu0mjfF{#1z literal 0 HcmV?d00001 diff --git a/core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png b/core/img/filetypes/application-vnd.oasis.opendocument.spreadsheet.png new file mode 100644 index 0000000000000000000000000000000000000000..abc38d4310c9e73abb1f664a97dacb3708fcb2cc GIT binary patch literal 436 zcmV;l0ZaagP)ehz*L3RVxJt5er@XHZD$Pa&>ShxCX%z3W`EV6bnk{eu91jHxbOBE(Niz z8e@!2G`UX3_llAB!W(`E?s@lIu3%Xf0KhN|=(_HJsk_djy0WzBW-$POh~|i>L`0=l zt946E9iLpVNXF4A$IWKbk@I_({a?E!;QErWuV8oYm-YDx?(-x`AOpZ!WdSdP1X(qk z6LEFZgCvQl9onfLefX-J4@1ljA_#-8Oam1%@?i)`5>egW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7UGlTYZYHKCbMNx^ zO|ztFmMmst>cy0HImb6ON~@FM(f%HQ1t_<753<5_jVm!l2kQzlSCE$#09jd)bWKn> z21}-Fw^Z%`IJN)@ASD#HMT(>pS3Xm`bC*^m|LBLJGFM!ZLS zi-;g1#1L))UIeW`YlBh{QzV28|Lqe1F$P3d0N=KV_jr+8fcO@b0w_o+5<)EM%|<&C4EztpdHb5n6#6PFVxYPPKJt*P(b4I z`41L#gSD2-YMwl}M?#^|sHE|AG;4r9zq~4JNPk3gaowP`CV3$Q#pOlA?}-8D<8c9K z3vf0XpI%L_J29r;$-JwxjkVS)Ubp^q^Fh6K^Dn?1ML>Y~3yvxS99~^dWB>pF07*qo IM6N<$f|eWirvLx| literal 0 HcmV?d00001 diff --git a/core/img/filetypes/application-x-gzip.png b/core/img/filetypes/application-x-gzip.png new file mode 100644 index 0000000000000000000000000000000000000000..55dd0f75366f0b7998b8b4a763b8a8dcc2a91b07 GIT binary patch literal 652 zcmV;70(1R|P)o`*ydp1-8p1Dr(>xn7O=%hWZ9B zfuTNupqcs{iUS4)f*6WRFbIwg$iV2#?OSyggWEcS6AXHwpiWR9|Noy;!QJ_vs(xLb z+`jn0-LDv16mA8Bq_0R8_^|kux~X_LujRk|{Ye zYg;xqzqamv`Rcv3m+54;R)-LtFD)-0URYRU*op4994@MIh`+aIbUD zm)<;mbUy+&QcBaNX)rTP6;-8_f{`Fps0d~{KgMu4B*i!dZdM_1M?~r`8ykOlJsYP0 zynFp>zbGalaHj(5)f1-~O;#9B78s5e8H~pah7*>Kp95g^_)&7VL*Ct`Yq#0m`A)mD z#pm@8b*1W<8D;jJ8G_0T=^Ao9U~s5c@Z;Mjq-1iQQM#5gYcVraol4Dd6@)-c6(K|b z%oLRjK<-*Z3X(fYDM%@}3TktJh~N$}M*?8(s0g3mzL>)dRY6Nea)(Ii``>^pSS*0! zZX{JwN`%;}aWhnVMWtj)H^VIa0niL$xI3mwtV$0EX+HLTv?hX-9zuw7fI7HS@(fc! zMTk{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L$xI3mwtV$0EX+HLTv?hX-9zuw7fI7HS@(fc! zMTk{JOo Date: Tue, 21 Feb 2012 10:22:17 -0500 Subject: [PATCH 29/70] restore redirect after checkLoggedIn --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index ee32d31bfd0..aa9fcdec65f 100644 --- a/lib/util.php +++ b/lib/util.php @@ -255,7 +255,7 @@ class OC_Util { 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', TRUE )); exit(); } } From 21f8d0992f1ae389d8c9acc870927285e9413a96 Mon Sep 17 00:00:00 2001 From: Marvin Thomas Rabe Date: Tue, 21 Feb 2012 18:28:27 +0100 Subject: [PATCH 30/70] Added missing files --- apps/bookmarks/img/delete.png | Bin 0 -> 275 bytes apps/bookmarks/img/edit.png | Bin 0 -> 310 bytes apps/media/css/music.css | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 apps/bookmarks/img/delete.png create mode 100644 apps/bookmarks/img/edit.png diff --git a/apps/bookmarks/img/delete.png b/apps/bookmarks/img/delete.png new file mode 100644 index 0000000000000000000000000000000000000000..bc0c782882deaa4f9ecf1676592ddba0cc9aacbc GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4%Pm*(PLD+t=F;b z*eX3n(MkRcKXtZMbAR7WZg&GK3{-9d P-NxYQ>gTe~DWM4f<>O_1 literal 0 HcmV?d00001 diff --git a/apps/bookmarks/img/edit.png b/apps/bookmarks/img/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..9993a092df101d4b2796379ac6f1cbe62f131a3c GIT binary patch literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4=coeX%YV7tbaA(MAa9*?eMT*!Qy-Sie zj Date: Tue, 21 Feb 2012 20:05:02 +0100 Subject: [PATCH 31/70] Move the redirect_url from linkTo function to the checkLoggedIn function --- lib/helper.php | 14 ++++---------- lib/util.php | 7 ++++--- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/helper.php b/lib/helper.php index b1e6d053a19..2f71bdad2dc 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -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; diff --git a/lib/util.php b/lib/util.php index aa9fcdec65f..1b1e29b6749 100644 --- a/lib/util.php +++ b/lib/util.php @@ -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', TRUE )); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' ).'?redirect_url='.urlencode($_SERVER["REQUEST_URI"])); exit(); } } From 86d2927c02c09d6642268891e995bf9d0a11782c Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 21 Feb 2012 20:10:40 +0100 Subject: [PATCH 32/70] Calendar: Correct calendarcolor format for ical color property --- apps/calendar/ajax/updatecalendar.php | 10 +++++++++- apps/calendar/appinfo/info.xml | 2 +- apps/calendar/appinfo/update.php | 17 +++++++++++++++++ apps/calendar/js/calendar.js | 2 +- apps/calendar/lib/calendar.php | 24 ++++++++++++------------ 5 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 apps/calendar/appinfo/update.php diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php index 5add6d92bfa..20c225d8a29 100644 --- a/apps/calendar/ajax/updatecalendar.php +++ b/apps/calendar/ajax/updatecalendar.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); diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 46292af3db1..4ac3c5bf099 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -2,7 +2,7 @@ calendar Calendar - 0.2 + 0.2.1 AGPL Georg Ehrke, Bart Visscher, Jakob Sack 2 diff --git a/apps/calendar/appinfo/update.php b/apps/calendar/appinfo/update.php new file mode 100644 index 00000000000..375816a403e --- /dev/null +++ b/apps/calendar/appinfo/update.php @@ -0,0 +1,17 @@ +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)); + } +} diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 517d2ce128b..ba8e293819a 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -478,7 +478,7 @@ Calendar={ colors[i].label = $(elm).text(); }); for (var i in colors) { - picker.append(''); + picker.append(''); } picker.delegate(".calendar-colorpicker-color", "click", function() { $(obj).val($(this).attr('rel')); diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 679649582d8..277539af97d 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -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, From d3e6ea6ac000e6276c70c988237f7e8c548d2881 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 21 Feb 2012 20:28:24 +0100 Subject: [PATCH 33/70] Bookmarks: uses the core action icons --- apps/bookmarks/img/delete.png | Bin 275 -> 0 bytes apps/bookmarks/img/edit.png | Bin 310 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/bookmarks/img/delete.png delete mode 100644 apps/bookmarks/img/edit.png diff --git a/apps/bookmarks/img/delete.png b/apps/bookmarks/img/delete.png deleted file mode 100644 index bc0c782882deaa4f9ecf1676592ddba0cc9aacbc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 275 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4%Pm*(PLD+t=F;b z*eX3n(MkRcKXtZMbAR7WZg&GK3{-9d P-NxYQ>gTe~DWM4f<>O_1 diff --git a/apps/bookmarks/img/edit.png b/apps/bookmarks/img/edit.png deleted file mode 100644 index 9993a092df101d4b2796379ac6f1cbe62f131a3c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4=coeX%YV7tbaA(MAa9*?eMT*!Qy-Sie zj Date: Tue, 21 Feb 2012 10:11:26 +0100 Subject: [PATCH 34/70] Remove my FIXME comments when I've fixed it :-P --- apps/contacts/ajax/saveproperty.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 0c9e0cc7836..6f8366243fe 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -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); From e0c92662f837161fc45cc6bd60485d113b324345 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 21 Feb 2012 23:15:26 +0100 Subject: [PATCH 35/70] JS fix on address book creation. --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 0e06b650a18..11661320c59 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -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); From c5c843bfefb9e678b65bf30c42082676db07bc3c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 21 Feb 2012 23:19:13 +0100 Subject: [PATCH 36/70] Improved upgrading VCARD v. 2.1 => 3.0. Improved import of malformed cards. Remove duplicate code. --- apps/contacts/lib/vcard.php | 214 ++++++++++++++++++++++-------------- 1 file changed, 129 insertions(+), 85 deletions(-) diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 17e95adff71..0b8d95a2d97 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -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 @@ -114,58 +226,17 @@ class OC_Contacts_VCard{ $card = OC_VObject::parse($data); if(!is_null($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'); @@ -183,54 +254,23 @@ 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)){ - 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; } /** @@ -304,7 +344,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)); @@ -381,10 +421,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; From b3f3b8c23f4f07a4d38e952f4d77827380c34b58 Mon Sep 17 00:00:00 2001 From: Marvin Thomas Rabe Date: Tue, 21 Feb 2012 22:31:35 +0100 Subject: [PATCH 37/70] UI problems solved. Bookmarks app updated. --- apps/bookmarks/css/bookmarks.css | 5 ++++- apps/bookmarks/js/bookmarks.js | 3 +++ apps/bookmarks/templates/list.php | 10 ++++++---- apps/bookmarks/templates/settings.php | 2 +- apps/contacts/css/contacts.css | 4 ++-- apps/contacts/js/contacts.js | 6 +++--- apps/gallery/css/styles.css | 6 +++--- apps/media/js/collection.js | 24 +++++++++++++----------- apps/media/js/loader.js | 4 ++-- apps/media/js/music.js | 12 +++++------- apps/media/js/playlist.js | 8 ++++---- apps/media/js/scanner.js | 8 ++++---- core/css/styles.css | 9 +++++---- core/js/js.js | 22 +++++++++++----------- core/templates/layout.user.php | 4 ++-- settings/css/settings.css | 4 ++-- 16 files changed, 70 insertions(+), 61 deletions(-) diff --git a/apps/bookmarks/css/bookmarks.css b/apps/bookmarks/css/bookmarks.css index 8dfdc8a07b9..499a4e9c53e 100644 --- a/apps/bookmarks/css/bookmarks.css +++ b/apps/bookmarks/css/bookmarks.css @@ -1,4 +1,7 @@ -#content { overflow: auto; } +#content { overflow: auto; height: 100%; } +#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;} +#firstrun small { display: block; font-weight: normal; font-size: 0.5em; } +#firstrun #selections { font-size:0.8em; width: 100%; margin: 2em auto auto auto; clear: both; } .bookmarks_headline { font-size: large; diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index fadbbd5513a..328f88a45d9 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -35,6 +35,7 @@ function getBookmarks() { for(var i in bookmarks.data) { updateBookmarksList(bookmarks.data[i]); + $("#firstrun").hide(); } $('.bookmark_link').click(recordClick); @@ -71,6 +72,8 @@ function addOrEditBookmark(event) { var tags = encodeEntities($('#bookmark_add_tags').val()); var taglist = tags.split(' '); var tagshtml = ''; + $("#firstrun").hide(); + for ( var i=0, len=taglist.length; i' + taglist[i] + ' '; } diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index d44a0ecbcdb..bd33fe457fd 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -21,9 +21,11 @@

      - t('You have no bookmarks'); ?>
      -