From bcbebe390b2689de34f60d124d19c9154d531f5e Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 17 Feb 2012 21:33:39 +0100 Subject: [PATCH 01/19] Document OC_Response --- lib/response.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/response.php b/lib/response.php index 2fa0a5adcd..3765f509c1 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/19] 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 3765f509c1..9edae3603b 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/19] 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 c5115d1607..0a21ddd04b 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/19] 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 97b6b256c0..a985ee9d61 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 2d5cdea4d7..eb82d0d02a 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 4c0dfad617..e81597f23d 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 7d7ab23756..9e3f5876cd 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 cb416f0e41..5faa4aa6ac 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 c647e44c25..8673e4521d 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 138b65d1fd..97c0930860 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 ac813c2085..2907c616cf 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 912019a970..cbcbe54422 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 a267e02050..8fec713aa7 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 ede94dab2d..30caa2d23d 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 9bd460be35..18ea3022bc 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 6d3df6d97e..b1e6d053a1 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 43fb4413f0..4ba04fff3e 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 80d2cb0a86..57731d979d 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/19] 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 425c93c733..0016751a66 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 9763882100..5aad6a25f0 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 da87227449..b8de32ea58 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 0ade0e593d..1bcd0f08c8 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 f166790ba9..a29d3fb7e1 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 22d18b17ee..1879a89cee 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 c3dc2942ae..34803c75ae 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/19] 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 77f767cdb8..fadbbd5513 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/19] 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 9ae3ffa8d9..19f6a80a16 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/19] 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 dd593ddec9..7734129bd9 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 5e272991f2..679649582d 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/19] 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 6f1f52eafa..517d2ce128 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/19] 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 8d03271b3e..ad1cd18fa1 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/19] 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 eb32e84713..3e46a3dcc9 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 cc4a460253..57623797ae 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/19] 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 8f169a5732..880645ff79 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 4ba04fff3e..ee32d31bfd 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/19] 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 049a74278b..42739bdfba 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 0000000000..fc271f4e4b --- /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/19] 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 9edae3603b..a75135c017 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/19] 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 3079362574..c9d1dc30f0 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 408b595dc9..5be20964f4 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/19] 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 8dfbcb6fb1..298f1215e3 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/19] 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 c9d1dc30f0..d33f983a42 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/19] 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 016bd2b791..ff348403a9 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/19] 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 51fda6aed4..ba01adffb9 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) {