diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-07-21 13:14:52 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-07-21 13:14:52 +0200 |
commit | 5508a95065cc6bf772621d5222bc23115e7c4df2 (patch) | |
tree | 21e2fd6f59ab69ded122a51641bf867e57c2af9d | |
parent | 88f66460a36f7809289313b30ef4fbe58bd8cced (diff) | |
parent | 687c87bc5b4d4c04cdb05adcab2465d8dfbb34cc (diff) | |
download | nextcloud-server-5508a95065cc6bf772621d5222bc23115e7c4df2.tar.gz nextcloud-server-5508a95065cc6bf772621d5222bc23115e7c4df2.zip |
Merge branch 'master' into subadmin
78 files changed, 347 insertions, 613 deletions
diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 0b19e7e92f9..db04cdf2d49 100644 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -27,7 +27,7 @@ if (!$end){ } $start = new DateTime('@'.$start); $end = new DateTime('@'.$end); -$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$timezone = OC_Calendar_App::getTimezone(); $start->setTimezone(new DateTimeZone($timezone)); $end->setTimezone(new DateTimeZone($timezone)); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 1a13f2958c0..29e5ab5b0c8 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -9,7 +9,7 @@ * This class manages our app actions */ OC_Calendar_App::$l10n = new OC_L10N('calendar'); -OC_Calendar_App::$tz = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +OC_Calendar_App::$tz = OC_Calendar_App::getTimezone(); class OC_Calendar_App{ const CALENDAR = 'calendar'; const EVENT = 'event'; @@ -282,7 +282,17 @@ class OC_Calendar_App{ public static function getWeekofMonth(){ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } - + + /** + * @return (string) $timezone as set by user or the default timezone + */ + public static function getTimezone() { + return OCP\Config::getUserValue(OCP\User::getUser(), + 'calendar', + 'timezone', + date_default_timezone_get()); + } + /** * @brief checks the access for a calendar / an event * @param (int) $id - id of the calendar / event diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 140542bf4fb..34676830205 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -856,7 +856,7 @@ class OC_Calendar_Object{ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::DATE); $vevent->setDateTime('DTEND', $end, Sabre_VObject_Property_DateTime::DATE); }else{ - $timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); $start = new DateTime($from.' '.$fromtime, $timezone); $end = new DateTime($to.' '.$totime, $timezone); diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 560330f65e9..551489672b9 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -12,7 +12,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{ }else{ $searchquery[] = $query; } - $user_timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $user_timezone = OC_Calendar_App::getTimezone(); $l = new OC_l10n('calendar'); foreach($calendars as $calendar){ $objects = OC_Calendar_Object::all($calendar['id']); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 5aead47888b..8d881498768 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -187,20 +187,14 @@ Contacts={ // Name has changed. Update it and reorder. $('#fn').change(function(){ var name = $('#fn').val().strip_tags(); - var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]'); + var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]').detach(); $(item).find('a').html(name); Contacts.UI.Card.fn = name; - var added = false; - $('.contacts li[data-bookid="'+Contacts.UI.Card.bookid+'"]').each(function(){ - if ($(this).text().toLowerCase() > name.toLowerCase()) { - $(this).before(item).fadeIn('fast'); - added = true; - return false; - } + Contacts.UI.Contacts.insertContact({ + contactlist:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]'), + contacts:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"] li'), + contact:item, }); - if(!added) { - $('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item); - } Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id); }); @@ -321,12 +315,15 @@ Contacts={ if(jsondata.status == 'success'){ if(bookid == 'unknown') { bookid = jsondata.data.addressbookid; - var entry = Contacts.UI.Card.createEntry(jsondata.data); - $('#contacts ul[data-id="'+bookid+'"]').append(entry); + var contact = Contacts.UI.Contacts.insertContact({ + contactlist:$('#contacts ul[data-id="'+bookid+'"]'), + data:jsondata.data + }); } $('#contacts li[data-id="'+newid+'"],#contacts h3[data-id="'+bookid+'"]').addClass('active'); $('#contacts ul[data-id="'+bookid+'"]').slideDown(300); Contacts.UI.Card.loadContact(jsondata.data, bookid); + Contacts.UI.Contacts.scrollTo(newid); } else { OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } @@ -374,9 +371,6 @@ Contacts={ Contacts.UI.Card.add(';;;;;', '', '', true); return false; }, - createEntry:function(data) { - return $('<li data-id="'+data.id+'" data-bookid="'+data.addressbookid+'" role="button"><a href="'+OC.linkTo('contacts', 'index.php')+'&id='+data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+data.id+') no-repeat scroll 0% 0% transparent;">'+data.displayname+'</a></li>'); - }, add:function(n, fn, aid, isnew){ // add a new contact console.log('Adding ' + fn); aid = aid?aid:$('#contacts h3.active').first().data('id'); @@ -1503,6 +1497,33 @@ Contacts={ dropAddressbook:function(event, dragitem, droptarget) { alert('Dropping address books not implemented yet'); }, + /** + * @params params An object with the propeties 'contactlist':a jquery object of the ul to insert into, + * 'contacts':a jquery object of all items in the list and either 'data': an object with the properties + * id, addressbookid and displayname or 'contact': a listitem to be inserted directly. + * If 'contacts' is defined the new contact will be inserted alphabetically into the list, otherwise + * it will be appended. + */ + insertContact:function(params) { + var contact = params.data + ? $('<li data-id="'+params.data.id+'" data-bookid="'+params.data.addressbookid+'" role="button"><a href="'+OC.linkTo('contacts', 'index.php')+'&id='+params.data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+params.data.id+') no-repeat scroll 0% 0% transparent;">'+params.data.displayname+'</a></li>') + : params.contact; + var added = false; + var name = params.data ? params.data.displayname.toLowerCase() : contact.find('a').text().toLowerCase(); + if(params.contacts) { + params.contacts.each(function() { + if ($(this).text().toLowerCase() > name) { + $(this).before(contact); + added = true; + return false; + } + }); + } + if(!added || !params.contacts) { + params.contactlist.append(contact); + } + return contact; + }, // Reload the contacts list. update:function(params){ if(!params) { params = {}; } @@ -1564,7 +1585,7 @@ Contacts={ for(var c in book.contacts) { if(book.contacts[c].id == undefined) { continue; } if(!$('#contacts li[data-id="'+book.contacts[c]['id']+'"]').length) { - var contact = Contacts.UI.Card.createEntry(book.contacts[c]); + var contact = Contacts.UI.Contacts.insertContact({contactlist:contactlist, contacts:contacts, data:book.contacts[c]}); if(c == self.batchnum-10) { contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) { $(this).unbind(event); @@ -1576,17 +1597,6 @@ Contacts={ } }); } - var added = false; - contacts.each(function(){ - if ($(this).text().toLowerCase() > book.contacts[c].displayname.toLowerCase()) { - $(this).before(contact); - added = true; - return false; - } - }); - if(!added) { - contactlist.append(contact); - } } } }); @@ -1617,9 +1627,10 @@ Contacts={ }, scrollTo:function(id){ var item = $('#contacts li[data-id="'+id+'"]'); + console.log('scrollTo, found item '+id+'? ' + item.length); if(item) { - $('.contacts').animate({ - scrollTop: $('#contacts li[data-id="'+id+'"]').offset().top-20}, 'slow','swing'); + $('#contacts').animate({ + scrollTop: item.offset().top-40}, 'slow','swing'); } } } @@ -1841,9 +1852,10 @@ $(document).ready(function(){ if(numfiles != uploadedfiles) { Contacts.UI.notify({message:t('contacts', 'Not all files uploaded. Retrying...')}); retries += 1; - if(retries > 0) { + if(retries > 3) { numfiles = uploadedfiles = retries = aid = 0; uploadingFiles = {}; + $('#uploadprogressbar').fadeOut(); OC.dialogs.alert(t('contacts', 'Something went wrong with the upload, please retry.'), t('contacts', 'Error')); return; } @@ -1917,6 +1929,7 @@ $(document).ready(function(){ }); } } else { + $('#uploadprogressbar').fadeOut(); OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } }); diff --git a/apps/contacts/lib/VCFExportPlugin.php b/apps/contacts/lib/VCFExportPlugin.php index 6554cb258e8..9a64c964b06 100644 --- a/apps/contacts/lib/VCFExportPlugin.php +++ b/apps/contacts/lib/VCFExportPlugin.php @@ -31,7 +31,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { public function initialize(Sabre_DAV_Server $server) { $this->server = $server; - $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); + $this->server->subscribeEvent('beforeMethod', array($this,'beforeMethod'), 90); } @@ -49,7 +49,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { if ($this->server->httpRequest->getQueryString()!='export') return; // splitting uri - list($uri) = explode('?',$uri,2); + list($uri) = explode('?', $uri, 2); $node = $this->server->tree->getNodeForPath($uri); @@ -60,12 +60,12 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin { $aclPlugin->checkPrivileges($uri, '{DAV:}read'); } - $this->server->httpResponse->setHeader('Content-Type','text/directory'); + $this->server->httpResponse->setHeader('Content-Type', 'text/directory'); $this->server->httpResponse->sendStatus(200); $nodes = $this->server->getPropertiesForPath($uri, array( '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data', - ),1); + ), 1); $this->server->httpResponse->sendBody($this->generateVCF($nodes)); diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php index 6239aec49ef..3344e3d6939 100644 --- a/apps/contacts/lib/hooks.php +++ b/apps/contacts/lib/hooks.php @@ -61,8 +61,8 @@ class OC_Contacts_Hooks{ static public function getCalenderSources($parameters) { $base_url = OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id='; foreach(OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) { - $parameters['sources'][] = - array( + $parameters['sources'][] + = array( 'url' => $base_url.'birthday_'. $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', @@ -91,18 +91,24 @@ class OC_Contacts_Hooks{ $date = new DateTime($birthday); $vevent = new OC_VObject('VEVENT'); //$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); - $vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE); + $vevent->setDateTime('DTSTART', $date, + Sabre_VObject_Element_DateTime::DATE); $vevent->setString('DURATION', 'P1D'); - $vevent->setString('UID', substr(md5(rand().time()),0,10)); + $vevent->setString('UID', substr(md5(rand().time()), 0, 10)); // DESCRIPTION? $vevent->setString('RRULE', 'FREQ=YEARLY'); - $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday')); + $title = str_replace('{name}', + $vcard->getAsString('FN'), + OC_Contacts_App::$l10n->t('{name}\'s Birthday')); $parameters['events'][] = array( 'id' => 0,//$card['id'], 'vevent' => $vevent, 'repeating' => true, 'summary' => $title, - 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Contacts " . OCP\App::getAppVersion('contacts') . "\n" . $vevent->serialize() . "END:VCALENDAR" + 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\n" + . "PRODID:ownCloud Contacts " + . OCP\App::getAppVersion('contacts') . "\n" + . $vevent->serialize() . "END:VCALENDAR" ); } } diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 6b9a4c04f1e..ca171e792fc 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -212,7 +212,7 @@ class OC_Contacts_VCard{ // Add version if needed if($version && $version < '3.0') { $upgrade = true; - OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version, OCP\Util::DEBUG); } foreach($vcard->children as &$property){ // Decode string properties and remove obsolete properties. diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index e0020537563..46471911d94 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -31,9 +31,7 @@ class OC_CryptStream{ public static $sourceStreams=array(); private $source; private $path; - private $readBuffer;//for streams that dont support seeking private $meta=array();//header/meta for source stream - private $count; private $writeCache; private $size; private static $rootView; @@ -100,7 +98,6 @@ class OC_CryptStream{ public function stream_write($data){ $length=strlen($data); - $written=0; $currentPos=ftell($this->source); if($this->writeCache){ $data=$this->writeCache.$data; diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 5e34deb2337..8a5e993b1d0 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -15,8 +15,6 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ private $root; private $share; - private static $tempFiles=array(); - public function __construct($params){ $this->host=$params['host']; $this->user=$params['user']; diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php index 68481b4e66b..97796bca128 100644 --- a/apps/files_external/tests/ftp.php +++ b/apps/files_external/tests/ftp.php @@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){ }else{ class Test_Filestorage_FTP extends Test_FileStorage { private $config; - private $id; public function setUp(){ $id=uniqid(); diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php index 08116f0e748..806db5a6aaa 100644 --- a/apps/files_external/tests/google.php +++ b/apps/files_external/tests/google.php @@ -28,7 +28,6 @@ if(!is_array($config) or !isset($config['google']) or !$config['google']['run']) class Test_Filestorage_Google extends Test_FileStorage { private $config; - private $id; public function setUp(){ $id=uniqid(); diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php index e1495b7480d..001ef842276 100644 --- a/apps/files_external/tests/smb.php +++ b/apps/files_external/tests/smb.php @@ -14,7 +14,6 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']){ }else{ class Test_Filestorage_SMB extends Test_FileStorage { private $config; - private $id; public function setUp(){ $id=uniqid(); diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php index f0bde6ed605..1520c9473d3 100644 --- a/apps/files_external/tests/swift.php +++ b/apps/files_external/tests/swift.php @@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']){ }else{ class Test_Filestorage_SWIFT extends Test_FileStorage { private $config; - private $id; public function setUp(){ $id=uniqid(); diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php index 144659819b6..14abbef2cbf 100644 --- a/apps/files_external/tests/webdav.php +++ b/apps/files_external/tests/webdav.php @@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']) }else{ class Test_Filestorage_DAV extends Test_FileStorage { private $config; - private $id; public function setUp(){ $id=uniqid(); diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index 4138fc2b399..32fd2124429 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -67,7 +67,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { public function rmdir($path) { // The folder will be removed from the database, but won't be deleted from the owner's filesystem OC_Share::unshareFromMySelf($this->datadir.$path); - $this->clearFolderSizeCache($path); } public function opendir($path) { @@ -190,7 +189,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { public function filesize($path) { if ($path == "" || $path == "/" || $this->is_dir($path)) { - return $this->getFolderSize($path); + return 0; } else { $source = $this->getSource($path); if ($source) { @@ -200,55 +199,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { } } - public function getFolderSize($path) { - return 0; //depricated - } - - private function calculateFolderSize($path) { - if ($this->is_file($path)) { - $path = dirname($path); - } - $size = 0; - if ($dh = $this->opendir($path)) { - while (($filename = readdir($dh)) !== false) { - if ($filename != "." && $filename != "..") { - $subFile = $path."/".$filename; - if ($this->is_file($subFile)) { - $size += $this->filesize($subFile); - } else { - $size += $this->getFolderSize($subFile); - } - } - } - if ($size > 0) { - $dbpath = rtrim($this->datadir.$path, "/"); -// $query = OCP\DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)"); -// $result = $query->execute(array($dbpath, $size)); - } - } - return $size; - } - - private function clearFolderSizeCache($path) { - $path = rtrim($path, "/"); - $path = preg_replace('{(/)\1+}', "/", $path); - if ($this->is_file($path)) { - $path = dirname($path); - } - $dbpath = rtrim($this->datadir.$path, "/"); -// $query = OCP\DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?"); -// $result = $query->execute(array($dbpath)); - if ($path != "/" && $path != "") { - $parts = explode("/", $path); - $part = array_pop($parts); - if (empty($part)) { - array_pop($parts); - } - $parent = implode("/", $parts); - $this->clearFolderSizeCache($parent); - } - } - public function is_readable($path) { return true; } @@ -341,9 +291,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { OCP\Util::emitHook('OC_Filestorage_Shared', 'file_put_contents', $info); $storage = OC_Filesystem::getStorage($source); $result = $storage->file_put_contents($this->getInternalPath($source), $data); - if ($result) { - $this->clearFolderSizeCache($path); - } return $result; } } @@ -365,7 +312,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { } else { OC_Share::unshareFromMySelf($target); } - $this->clearFolderSizeCache($this->getInternalPath($target)); return true; } @@ -401,8 +347,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { } else { OC_Share::setTarget($oldTarget, $newTarget); } - $this->clearFolderSizeCache($this->getInternalPath($oldTarget)); - $this->clearFolderSizeCache($this->getInternalPath($newTarget)); return true; } @@ -413,9 +357,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { if ($this->is_writable($path2)) { $tmpFile = $this->toTmpFile($path1); $result = $this->fromTmpFile($tmpFile, $path2); - if ($result) { - $this->clearFolderSizeCache($path2); - } return $result; } else { return false; @@ -451,9 +392,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { if ($source) { $storage = OC_Filesystem::getStorage($source); $result = $storage->fromTmpFile($tmpFile, $this->getInternalPath($source)); - if ($result) { - $this->clearFolderSizeCache($path); - } return $result; } } else { @@ -520,7 +458,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { $source = $this->getSource($path); if ($source) { $storage = OC_Filesystem::getStorage($source); - return $storage->touch($this->getInternalPath($source),$time); + return $storage->touch($this->getInternalPath($source),$mtime); } } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 0ce884c3ea0..f146676757d 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -227,13 +227,13 @@ class Storage { }
$versions = array_reverse( $versions );
-
+
foreach( $versions as $key => $value ) {
// flag the first matched file in array (which will have latest modification date) as current version
- if ( $versions[$key]['fileMatch'] ) {
+ if ( $value['fileMatch'] ) {
- $versions[$key]['cur'] = 1;
+ $value['cur'] = 1;
break;
}
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 39d6d3aded1..701949d4d80 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -58,7 +58,7 @@ class OC_Gallery_Album { return $stmt->execute($args); } - public static function removeByName($owner, $name) { self::remove($ownmer, $name); } + public static function removeByName($owner, $name) { self::remove($owner, $name); } public static function removeByPath($owner, $path) { self::remove($owner, null, $path); } public static function removeByParentPath($owner, $parent) { self::remove($owner, null, null, $parent); } diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index b6ade3d1b1e..575d962dbe3 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -29,7 +29,6 @@ class DatabaseManager { $stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)'); $stmt->execute(array(\OCP\USER::getUser(), $path, $width, $height)); $ret = array('path' => $path, 'width' => $width, 'height' => $height); - unset($image); $dir = dirname($path); $this->cache[$dir][$path] = $ret; return $ret; diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index 754734e609e..e36d26d3191 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -33,7 +33,7 @@ class TilesLine { } public function setAvailableSpace($space) { - $available_space = $space; + $this->available_space = $space; } public function getTilesCount() { diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index d35cca150b2..d5a093338cc 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -271,7 +271,6 @@ class OC_MEDIA_AMPACHE{ </root>"); return; } - global $SITEROOT; $filter=$params['filter']; $albums=OC_MEDIA_COLLECTION::getAlbums($filter); $artist=OC_MEDIA_COLLECTION::getArtistName($filter); diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index e65930f551d..cacab8e959f 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -27,7 +27,6 @@ class OC_MEDIA_COLLECTION{ public static $uid; private static $artistIdCache=array(); private static $albumIdCache=array(); - private static $songIdCache=array(); private static $queries=array(); /** @@ -152,7 +151,7 @@ class OC_MEDIA_COLLECTION{ return $artistId; }else{ $query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_artists` (`artist_name`) VALUES (?)"); - $result=$query->execute(array($name)); + $query->execute(array($name)); return self::getArtistId($name);; } } diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 9e687a4af2c..54502f42575 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -27,12 +27,12 @@ class OC_MEDIA{ * @param array $params, parameters passed from OC_Hook */ public static function loginListener($params){ - if(isset($_POST['user']) and $_POST['password']){ - $name=$_POST['user']; + if(isset($params['uid']) and $params['password']){ + $name=$params['uid']; $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?"); $uid=$query->execute(array($name))->fetchAll(); if(count($uid)==0){ - $password=hash('sha256',$_POST['password']); + $password=hash('sha256',$params['password']); $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_users (user_id, user_password_sha256) VALUES (?, ?);"); $query->execute(array($name,$password)); } diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php index 42cd9c90f64..c1765640c5d 100644 --- a/apps/remoteStorage/lib_remoteStorage.php +++ b/apps/remoteStorage/lib_remoteStorage.php @@ -17,12 +17,11 @@ class OC_remoteStorage { $user=OCP\USER::getUser(); $query=OCP\DB::prepare("SELECT token FROM *PREFIX*authtoken WHERE user=? AND appUrl=? AND category=? LIMIT 1"); $result=$query->execute(array($user, $appUrl, $categories)); - $ret = array(); if($row=$result->fetchRow()) { - return base64_encode('remoteStorage:'.$row['token']); - } else { - return false; - } + return base64_encode('remoteStorage:'.$row['token']); + } else { + return false; + } } public static function getAllTokens() { @@ -42,13 +41,13 @@ class OC_remoteStorage { public static function deleteToken($token) { $user=OCP\USER::getUser(); $query=OCP\DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?"); - $result=$query->execute(array($token,$user)); + $query->execute(array($token,$user)); return 'unknown';//how can we see if any rows were affected? } private static function addToken($token, $appUrl, $categories){ $user=OCP\USER::getUser(); $query=OCP\DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)"); - $result=$query->execute(array($token,$appUrl,$user,$categories)); + $query->execute(array($token,$appUrl,$user,$categories)); } public static function createCategories($appUrl, $categories) { $token=uniqid(); diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php index 188e179236a..d98fdbf3888 100644 --- a/apps/tasks/ajax/addtask.php +++ b/apps/tasks/ajax/addtask.php @@ -22,7 +22,7 @@ $request['description'] = null; $vcalendar = OC_Task_App::createVCalendarFromRequest($request); $id = OC_Calendar_Object::add($cid, $vcalendar->serialize()); -$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$user_timezone = OC_Calendar_App::getTimezone(); $task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); OCP\JSON::success(array('task' => $task)); diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php deleted file mode 100644 index d86232e2da5..00000000000 --- a/apps/tasks/ajax/addtaskform.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -// Init owncloud -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('tasks'); - -$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true); -$category_options = OC_Calendar_App::getCategoryOptions(); -$percent_options = range(0, 100, 10); -$priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OCP\Template('tasks','part.addtaskform'); -$tmpl->assign('calendars',$calendars); -$tmpl->assign('category_options', $category_options); -$tmpl->assign('percent_options', $percent_options); -$tmpl->assign('priority_options', $priority_options); -$tmpl->assign('details', new OC_VObject('VTODO')); -$tmpl->assign('categories', ''); -$page = $tmpl->fetchPage(); - -OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php deleted file mode 100644 index 77ecff13e66..00000000000 --- a/apps/tasks/ajax/edittask.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -// Init owncloud -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('tasks'); -OCP\JSON::callCheck(); - -$l10n = new OC_L10N('tasks'); - -$id = $_POST['id']; -$vcalendar = OC_Calendar_App::getVCalendar($id); - -$errors = OC_Task_App::validateRequest($_POST); -if (!empty($errors)) { - OCP\JSON::error(array('data' => array( 'errors' => $errors ))); - exit(); -} - -OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar); -OC_Calendar_Object::edit($id, $vcalendar->serialize()); - -$priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OCP\Template('tasks','part.details'); -$tmpl->assign('priority_options', $priority_options); -$tmpl->assign('details', $vcalendar->VTODO); -$tmpl->assign('id', $id); -$page = $tmpl->fetchPage(); - -$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); -$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); - -OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task ))); diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php deleted file mode 100644 index e5a0a7297c5..00000000000 --- a/apps/tasks/ajax/edittaskform.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -// Init owncloud -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('tasks'); - -$id = $_GET['id']; -$details = OC_Calendar_App::getVCalendar($id)->VTODO; -$categories = $details->getAsString('CATEGORIES'); - -$category_options = OC_Calendar_App::getCategoryOptions(); -$percent_options = range(0, 100, 10); -$priority_options = OC_Task_App::getPriorityOptions(); - -$tmpl = new OCP\Template('tasks','part.edittaskform'); -$tmpl->assign('category_options', $category_options); -$tmpl->assign('percent_options', $percent_options); -$tmpl->assign('priority_options', $priority_options); -$tmpl->assign('id',$id); -$tmpl->assign('details',$details); -$tmpl->assign('categories', $categories); -$page = $tmpl->fetchPage(); - -OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php deleted file mode 100644 index 4ce469e0c9c..00000000000 --- a/apps/tasks/ajax/getdetails.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -// Init owncloud -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('tasks'); - -$l10n = new OC_L10N('tasks'); - -$id = $_GET['id']; -$task = OC_Calendar_Object::find($id); -$details = OC_VObject::parse($task['calendardata']); -if (!$details){ - OCP\JSON::error(); - exit; -} - -$priority_options = OC_Task_App::getPriorityOptions(); -$tmpl = new OCP\Template('tasks','part.details'); -$tmpl->assign('priority_options', $priority_options); -$tmpl->assign('details',$details->VTODO); -$tmpl->assign('id',$id); -$page = $tmpl->fetchPage(); - -OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); diff --git a/apps/tasks/ajax/gettasks.php b/apps/tasks/ajax/gettasks.php index 011730d0a13..b6183d9cb65 100644 --- a/apps/tasks/ajax/gettasks.php +++ b/apps/tasks/ajax/gettasks.php @@ -11,7 +11,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('tasks'); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true); -$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$user_timezone = OC_Calendar_App::getTimezone(); $tasks = array(); foreach( $calendars as $calendar ){ diff --git a/apps/tasks/ajax/update_property.php b/apps/tasks/ajax/update_property.php index f47040a77d4..679cfdefe48 100644 --- a/apps/tasks/ajax/update_property.php +++ b/apps/tasks/ajax/update_property.php @@ -39,7 +39,7 @@ switch($property) { $type = null; if ($due != 'false') { try { - $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); $due = new DateTime('@'.$due); $due->setTimezone($timezone); @@ -64,6 +64,6 @@ switch($property) { } OC_Calendar_Object::edit($id, $vcalendar->serialize()); -$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$user_timezone = OC_Calendar_App::getTimezone(); $task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone); OCP\JSON::success(array('data' => $task_info)); diff --git a/apps/tasks/index.php b/apps/tasks/index.php index 4ff304a5607..f1c4d1e765c 100644 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -21,8 +21,8 @@ OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addScript('tasks', 'tasks'); OCP\Util::addStyle('tasks', 'style'); -OCP\Util::addScript('contacts','jquery.multi-autocomplete'); -OCP\Util::addScript('','oc-vcategories'); +OCP\Util::addScript('contacts', 'jquery.multi-autocomplete'); +OCP\Util::addScript('', 'oc-vcategories'); OCP\App::setActiveNavigationEntry('tasks_index'); $categories = OC_Calendar_App::getCategoryOptions(); diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index bc92965bb0b..de627927507 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -469,67 +469,5 @@ $(document).ready(function(){ return false; }); - $('#tasks_addtaskform input[type="submit"]').live('click',function(){ - $.post('ajax/addtask.php',$('#tasks_addtaskform').serialize(),function(jsondata){ - if(jsondata.status == 'success'){ - $('#task_details').data('id',jsondata.data.id); - $('#task_details').html(jsondata.data.page); - $('#tasks_list').append(OC.Tasks.create_task_div(jsondata.data.task)); - } - else{ - alert(jsondata.data.message); - } - }, 'json'); - return false; - }); - - $('#tasks_edit').live('click',function(){ - var id = $('#task_details').data('id'); - $.getJSON('ajax/edittaskform.php',{'id':id},function(jsondata){ - if(jsondata.status == 'success'){ - $('#task_details').html(jsondata.data.page); - $('#task_details #categories').multiple_autocomplete({source: categories}); - } - else{ - alert(jsondata.data.message); - } - }); - return false; - }); - - $('#tasks_edittaskform #percent_complete').live('change',function(event){ - if ($(event.target).val() == 100){ - $('#tasks_edittaskform #complete').show(); - }else{ - $('#tasks_edittaskform #complete').hide(); - } - }); - - $('#tasks_edittaskform input[type="submit"]').live('click',function(){ - $.post('ajax/edittask.php',$('#tasks_edittaskform').serialize(),function(jsondata){ - $('.error_msg').remove(); - $('.error').removeClass('error'); - if(jsondata.status == 'success'){ - var id = jsondata.data.id; - $('#task_details').data('id',id); - $('#task_details').html(jsondata.data.page); - var task = jsondata.data.task; - $('#tasks .task[data-id='+id+']') - .data('task', task) - .html(OC.Tasks.create_task_div(task).html()); - } - else{ - var errors = jsondata.data.errors; - for (k in errors){ - $('#'+k).addClass('error') - .after('<span class="error_msg">'+errors[k]+'</span>'); - } - $('.error_msg').effect('highlight', {}, 3000); - $('.error').effect('highlight', {}, 3000); - } - }, 'json'); - return false; - }); - OCCategories.app = 'calendar'; }); diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php index 1b42968f0be..a97c6b95d1d 100644 --- a/apps/tasks/lib/app.php +++ b/apps/tasks/lib/app.php @@ -77,24 +77,24 @@ class OC_Task_App { public static function validateRequest($request) { $errors = array(); - if($request['summary'] == ''){ + if($request['summary'] == '') { $errors['summary'] = self::$l10n->t('Empty Summary'); } try { - $timezone = OCP\Config::getUserValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London"); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); new DateTime($request['due'], $timezone); } catch (Exception $e) { $errors['due'] = self::$l10n->t('Invalid date/time'); } - if ($request['percent_complete'] < 0 || $request['percent_complete'] > 100){ + if ($request['percent_complete'] < 0 || $request['percent_complete'] > 100) { $errors['percent_complete'] = self::$l10n->t('Invalid percent complete'); } - if ($request['percent_complete'] == 100 && !empty($request['completed'])){ + if ($request['percent_complete'] == 100 && !empty($request['completed'])) { try { - $timezone = OCP\Config::getUserValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London"); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); new DateTime($request['completed'], $timezone); } catch (Exception $e) { @@ -147,7 +147,7 @@ class OC_Task_App { $vtodo->setString('PRIORITY', $priority); if ($due) { - $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); $due = new DateTime($due, $timezone); $vtodo->setDateTime('DUE', $due); @@ -168,15 +168,15 @@ class OC_Task_App { $vtodo->__unset('PERCENT-COMPLETE'); } - if ($percent_complete == 100){ - if (!$completed){ + if ($percent_complete == 100) { + if (!$completed) { $completed = 'now'; } } else { $completed = null; } if ($completed) { - $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); + $timezone = OC_Calendar_App::getTimezone(); $timezone = new DateTimeZone($timezone); $completed = new DateTime($completed, $timezone); $vtodo->setDateTime('COMPLETED', $completed); diff --git a/apps/tasks/templates/part.addtaskform.php b/apps/tasks/templates/part.addtaskform.php deleted file mode 100644 index 0fad5592aa7..00000000000 --- a/apps/tasks/templates/part.addtaskform.php +++ /dev/null @@ -1,15 +0,0 @@ -<form id="tasks_addtaskform"> - <?php if(count($_['calendars'])==1): ?> - <input type="hidden" name="id" value="<?php echo $_['calendars'][0]['id']; ?>"> - <?php else: ?> - <label for="id"><?php echo $l->t('Calendar'); ?></label> - <select name="id" size="1"> - <?php foreach($_['calendars'] as $calendar): ?> - <option value="<?php echo $calendar['id']; ?>"><?php echo $calendar['displayname']; ?></option> - <?php endforeach; ?> - </select> - <br> - <?php endif; ?> - <?php echo $this->inc('part.taskform'); ?> - <input type="submit" name="submit" value="<?php echo $l->t('Create Task'); ?>"> -</form> diff --git a/apps/tasks/templates/part.details.php b/apps/tasks/templates/part.details.php deleted file mode 100644 index 89636b6e762..00000000000 --- a/apps/tasks/templates/part.details.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php if(isset($_['details']->SUMMARY)): ?> -<table> -<?php -echo $this->inc('part.property', array('label' => $l->t('Summary'), 'property' => $_['details']->SUMMARY)); -if(isset($_['details']->LOCATION)): - echo $this->inc('part.property', array('label' => $l->t('Location'), 'property' => $_['details']->LOCATION)); -endif; -if(isset($_['details']->CATEGORIES)): - echo $this->inc('part.property', array('label' => $l->t('Categories'), 'property' => $_['details']->CATEGORIES)); -endif; -if(isset($_['details']->DUE)): - echo $this->inc('part.property', array('label' => $l->t('Due'), 'property' => $_['details']->DUE[0])); -endif; -if(isset($_['details']->PRIORITY)): - echo $this->inc('part.property', array('label' => $l->t('Priority'), 'property' => $_['details']->PRIORITY[0], 'options' => $_['priority_options'])); -endif; -if($_['details']->__isset('PERCENT-COMPLETE') || isset($_['details']->COMPLETED)): -?> -<tr> - <th> - <?php echo $l->t('Complete') ?> - </th> - <td> -<?php if($_['details']->__isset('PERCENT-COMPLETE')): - echo $_['details']->__get('PERCENT-COMPLETE')->value.' % '; - endif; - if(isset($_['details']->COMPLETED)): - echo $l->t('on '). $l->l('datetime', $_['details']->COMPLETED[0]->getDateTime()); - endif; - echo '</tr>'; -endif; -if(isset($_['details']->DESCRIPTION)): - echo $this->inc('part.property', array('label' => $l->t('Description'), 'property' => $_['details']->DESCRIPTION)); -endif; ?> -</table> -<form> - <input type="button" id="tasks_delete" value="<?php echo $l->t('Delete');?>"> - <input type="button" id="tasks_edit" value="<?php echo $l->t('Edit');?>"> -</form> -<?php else: ?> -<?php //var_dump($_['details']); ?> -<?php endif ?> diff --git a/apps/tasks/templates/part.edittaskform.php b/apps/tasks/templates/part.edittaskform.php deleted file mode 100644 index fe123f07ac6..00000000000 --- a/apps/tasks/templates/part.edittaskform.php +++ /dev/null @@ -1,5 +0,0 @@ -<form id="tasks_edittaskform"> - <input type="hidden" name="id" value="<?php echo $_['id']; ?>"> - <?php echo $this->inc('part.taskform'); ?> - <input type="submit" name="submit" value="<?php echo $l->t('Update Task'); ?>"> -</form> diff --git a/apps/tasks/templates/part.property.php b/apps/tasks/templates/part.property.php deleted file mode 100644 index 591fd363e6f..00000000000 --- a/apps/tasks/templates/part.property.php +++ /dev/null @@ -1,22 +0,0 @@ -<tr> - <th> - <?php echo $_['label'] ?> - </th> - <td> - <?php - switch (get_class($_['property'])) - { - case 'Sabre_VObject_Element_DateTime': - echo $l->l('datetime', $_['property']->getDateTime()); - break; - default: - $value = $_['property']->value; - if (isset($_['options'])) - { - $value = $_['options'][$value]; - } - echo nl2br($value); - } - ?> - </td> -</tr> diff --git a/apps/tasks/templates/part.taskform.php b/apps/tasks/templates/part.taskform.php deleted file mode 100644 index 0a25ed33c91..00000000000 --- a/apps/tasks/templates/part.taskform.php +++ /dev/null @@ -1,36 +0,0 @@ - <label for="summary"><?php echo $l->t('Summary'); ?></label> - <input type="text" id="summary" name="summary" placeholder="<?php echo $l->t('Summary of the task');?>" value="<?php echo isset($_['details']->SUMMARY) ? $_['details']->SUMMARY[0]->value : '' ?>"> - <br> - <label for="location"><?php echo $l->t('Location'); ?></label> - <input type="text" id="location" name="location" placeholder="<?php echo $l->t('Location of the task');?>" value="<?php echo isset($_['details']->LOCATION) ? $_['details']->LOCATION[0]->value : '' ?>"> - <br> - <label for="categories"><?php echo $l->t('Categories'); ?></label> - <input id="categories" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? $_['categories'] : '' ?>"> - <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo OCP\image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a> - <br> - <label for="due"><?php echo $l->t('Due'); ?></label> - <input type="text" id="due" name="due" placeholder="<?php echo $l->t('Due date') ?>" value="<?php echo isset($_['details']->DUE) ? $l->l('datetime', $_['details']->DUE[0]->getDateTime()) : '' ?>"> - <br> - <select name="percent_complete" id="percent_complete"> - <?php - foreach($_['percent_options'] as $percent){ - echo '<option value="' . $percent . '"' . (($_['details']->__get('PERCENT-COMPLETE') && $percent == $_['details']->__get('PERCENT-COMPLETE')->value) ? ' selected="selected"' : '') . '>' . $percent . ' %</option>'; - } - ?> - </select> - <label for="percent_complete"><?php echo $l->t('Complete'); ?></label> - <span id="complete"<?php echo ($_['details']->__get('PERCENT-COMPLETE') && $_['details']->__get('PERCENT-COMPLETE')->value == 100) ? '' : ' style="display:none;"' ?>><label for="completed"><?php echo $l->t('completed on'); ?></label> - <input type="text" id="completed" name="completed" value="<?php echo isset($_['details']->COMPLETED) ? $l->l('datetime', $_['details']->COMPLETED[0]->getDateTime()) : '' ?>"></span> - <br> - <label for="priority"><?php echo $l->t('Priority'); ?></label> - <select name="priority"> - <?php - foreach($_['priority_options'] as $priority => $label){ - echo '<option value="' . $priority . '"' . ((isset($_['details']->PRIORITY) && $priority == $_['details']->PRIORITY->value) ? ' selected="selected"' : '') . '>' . $label . '</option>'; - } - ?> - </select> - <br> - <label for="description"><?php echo $l->t('Description'); ?></label><br> - <textarea placeholder="<?php echo $l->t('Description of the task');?>" name="description"><?php echo isset($_['details']->DESCRIPTION) ? $_['details']->DESCRIPTION[0]->value : '' ?></textarea> - <br> diff --git a/apps/tasks/templates/part.tasks.php b/apps/tasks/templates/part.tasks.php deleted file mode 100644 index 50be1cd6bed..00000000000 --- a/apps/tasks/templates/part.tasks.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php foreach( $_['tasks'] as $task ): ?> - <li data-id="<?php echo $task['id']; ?>"><a href="index.php?id=<?php echo $task['id']; ?>"><?php echo $task['name']; ?></a> </li> -<?php endforeach; ?> diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index 25927aff637..6bfccadad9a 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -1221,7 +1221,7 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common return $affected_rows; } - $result =& $this->db->_wrapResult($result, $this->result_types, + $result = $this->db->_wrapResult($result, $this->result_types, $result_class, $result_wrap_class, $this->limit, $this->offset); $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result)); return $result; diff --git a/lib/app.php b/lib/app.php index 77570afd512..d6b2904f3c2 100755 --- a/lib/app.php +++ b/lib/app.php @@ -27,7 +27,6 @@ * upgrading and removing apps. */ class OC_App{ - static private $init = false; static private $activeapp = ''; static private $navigation = array(); static private $settingsForms = array(); diff --git a/lib/archive/zip.php b/lib/archive/zip.php index ff405ce098b..b2d6674d639 100644 --- a/lib/archive/zip.php +++ b/lib/archive/zip.php @@ -11,7 +11,6 @@ class OC_Archive_ZIP extends OC_Archive{ * @var ZipArchive zip */ private $zip=null; - private $success=false; private $path; function __construct($source){ diff --git a/lib/connector/sabre/client.php b/lib/connector/sabre/client.php index 87f9d59b3ae..7e8f21264f9 100644 --- a/lib/connector/sabre/client.php +++ b/lib/connector/sabre/client.php @@ -68,18 +68,13 @@ class OC_Connector_Sabre_Client extends Sabre_DAV_Client { // Automatically follow redirects
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 5,
- CURLOPT_SSL_VERIFYPEER => true,
- //CURLOPT_SSL_VERIFYPEER => false,
);
-
+
if($this->trustedCertificates) {
$curlSettings[CURLOPT_CAINFO] = $this->trustedCertificates;
}
-
+
switch ($method) {
- case 'PUT':
- $curlSettings[CURLOPT_PUT] = true;
- break;
case 'HEAD' :
// do not read body with HEAD requests (this is neccessary because cURL does not ignore the body with HEAD
@@ -110,8 +105,15 @@ class OC_Connector_Sabre_Client extends Sabre_DAV_Client { $curlSettings[CURLOPT_PROXY] = $this->proxy;
}
- if ($this->userName) {
- $curlSettings[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC | CURLAUTH_DIGEST;
+ if ($this->userName && $this->authType) {
+ $curlType = 0;
+ if ($this->authType & self::AUTH_BASIC) {
+ $curlType |= CURLAUTH_BASIC;
+ }
+ if ($this->authType & self::AUTH_DIGEST) {
+ $curlType |= CURLAUTH_DIGEST;
+ }
+ $curlSettings[CURLOPT_HTTPAUTH] = $curlType;
$curlSettings[CURLOPT_USERPWD] = $this->userName . ':' . $this->password;
}
@@ -167,5 +169,5 @@ class OC_Connector_Sabre_Client extends Sabre_DAV_Client { return $response;
- }
+ }
}
\ No newline at end of file diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index f3f6541a8d4..0842fc4fc65 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -26,17 +26,33 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa /** * Creates a new file in the directory * - * data is a readable stream resource + * Data will either be supplied as a stream resource, or in certain cases + * as a string. Keep in mind that you may have to support either. + * + * After succesful creation of the file, you may choose to return the ETag + * of the new file here. + * + * The returned ETag must be surrounded by double-quotes (The quotes should + * be part of the actual string). + * + * If you cannot accurately determine the ETag, you should not return it. + * If you don't store the file exactly as-is (you're transforming it + * somehow) you should also not return an ETag. + * + * This means that if a subsequent GET to this new file does not exactly + * return the same contents of what was submitted here, you are strongly + * recommended to omit the ETag. * * @param string $name Name of the file - * @param resource $data Initial payload - * @return void + * @param resource|string $data Initial payload + * @return null|string */ public function createFile($name, $data = null) { $newPath = $this->path . '/' . $name; OC_Filesystem::file_put_contents($newPath,$data); + return OC_Connector_Sabre_Node::getETagPropertyForFile($newPath); } /** diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 4700dbf8b89..80f0a0ab4d8 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -26,13 +26,28 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D /** * Updates the data * + * The data argument is a readable stream resource. + * + * After a succesful put operation, you may choose to return an ETag. The + * etag must always be surrounded by double-quotes. These quotes must + * appear in the actual string you're returning. + * + * Clients may use the ETag from a PUT request to later on make sure that + * when they update the file, the contents haven't changed in the mean + * time. + * + * If you don't plan to store the file byte-by-byte, and you return a + * different object on a subsequent GET you are strongly recommended to not + * return an ETag, and just return null. + * * @param resource $data - * @return void + * @return string|null */ public function put($data) { OC_Filesystem::file_put_contents($this->path,$data); + return OC_Connector_Sabre_Node::getETagPropertyForFile($this->path); } /** @@ -79,9 +94,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D * @return mixed */ public function getETag() { - - return null; - + $properties = $this->getProperties(array(self::GETETAG_PROPERTYNAME)); + if (isset($properties[self::GETETAG_PROPERTYNAME])) { + return $properties[self::GETETAG_PROPERTYNAME]; + } + return $this->getETagPropertyForFile($this->path); } /** diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index 94382e68a1a..e95dcf02d27 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -108,7 +108,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { $locks = $this->getLocks($uri,false); $exists = false; - foreach($locks as $k=>$lock) { + foreach($locks as $lock) { if ($lock->token == $lockInfo->token) $exists = true; } diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index be315a0ffd9..3cb5412f09f 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -22,6 +22,7 @@ */ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IProperties { + const GETETAG_PROPERTYNAME = '{DAV:}getetag'; /** * The path to the current node @@ -178,7 +179,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @param array $properties * @return void */ - function getProperties($properties) { + public function getProperties($properties) { if (is_null($this->property_cache)) { $query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ? AND propertypath = ?' ); $result = $query->execute( array( OC_User::getUser(), $this->path )); @@ -200,4 +201,29 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr } return $props; } + + /** + * Returns the ETag surrounded by double-quotes for this path. + * @param string $path Path of the file + * @return string|null Returns null if the ETag can not effectively be determined + */ + static public function getETagPropertyForFile($path) { + $tag = OC_Filesystem::hash('md5', $path); + if (empty($tag)) { + return null; + } + $etag = '"'.$tag.'"'; + $query = OC_DB::prepare( 'INSERT INTO *PREFIX*properties (userid,propertypath,propertyname,propertyvalue) VALUES(?,?,?,?)' ); + $query->execute( array( OC_User::getUser(), $path, self::GETETAG_PROPERTYNAME, $etag )); + return $etag; + } + + /** + * Remove the ETag from the cache. + * @param string $path Path of the file + */ + static public function removeETagPropertyForFile($path) { + $query = OC_DB::prepare( 'DELETE FROM *PREFIX*properties WHERE userid = ? AND propertypath = ? AND propertyname = ?' ); + $query->execute( array( OC_User::getUser(), $path, self::GETETAG_PROPERTYNAME )); + } } diff --git a/lib/db.php b/lib/db.php index 2a06d72ea32..6f083d17cfb 100644 --- a/lib/db.php +++ b/lib/db.php @@ -33,8 +33,6 @@ class OC_DB { static private $MDB2=false; static private $PDO=false; static private $schema=false; - static private $affected=0; - static private $result=false; static private $inTransaction=false; static private $prefix=null; static private $type=null; @@ -222,7 +220,7 @@ class OC_DB { echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>'); OC_Log::write('core',self::$MDB2->getUserInfo(),OC_Log::FATAL); OC_Log::write('core',self::$MDB2->getMessage(),OC_Log::FATAL); - die( $error ); + die(); } // We always, really always want associative arrays @@ -519,8 +517,9 @@ class OC_DB { // Delete our temporary file unlink( $file2 ); - foreach($definition['tables'] as $name=>$table){ - self::dropTable($name); + $tables=array_keys($definition['tables']); + foreach($tables as $table){ + self::dropTable($table); } } diff --git a/lib/eventsource.php b/lib/eventsource.php index cf10660b94c..2a8c6b92902 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -36,7 +36,7 @@ class OC_EventSource{ header('Cache-Control: no-cache'); $this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true'; if($this->fallback){ - $fallBackId=$_GET['fallback_id']; + $this->fallBackId=$_GET['fallback_id']; header("Content-Type: text/html"); echo str_repeat('<span></span>'.PHP_EOL,10); //dummy data to keep IE happy }else{ diff --git a/lib/filecache.php b/lib/filecache.php index d956f34dc48..4b1774925c3 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -126,7 +126,7 @@ class OC_FileCache{ $query=OC_DB::prepare($sql); $result=$query->execute($arguments); if(OC_DB::isError($result)){ - OC_Log::write('files','error while updating file('.$path.') in cache',OC_Log::ERROR); + OC_Log::write('files','error while updating file('.$id.') in cache',OC_Log::ERROR); } } @@ -303,7 +303,7 @@ class OC_FileCache{ */ public static function increaseSize($path,$sizeDiff, $root=false){ if($sizeDiff==0) return; - $id=self::getId($path,''); + $id=self::getId($path,$root); while($id!=-1){//walk up the filetree increasing the size of all parent folders $query=OC_DB::prepare('UPDATE *PREFIX*fscache SET size=size+? WHERE id=?'); $query->execute(array($sizeDiff,$id)); diff --git a/lib/filecache/update.php b/lib/filecache/update.php index dd77f491ca0..93b632acb4e 100644 --- a/lib/filecache/update.php +++ b/lib/filecache/update.php @@ -207,7 +207,6 @@ class OC_FileCache_Update{ $cached=OC_FileCache_Cached::get($oldPath,$root); $oldSize=$cached['size']; - $size=$view->filesize($newPath); OC_FileCache::increaseSize(dirname($oldPath),-$oldSize,$root); OC_FileCache::increaseSize(dirname($newPath),$oldSize,$root); OC_FileCache::move($oldPath,$newPath); diff --git a/lib/filestorage.php b/lib/filestorage.php index 71ef4aed00b..e786127d525 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -24,7 +24,7 @@ * Provde a common interface to all different storage options */ abstract class OC_Filestorage{ - public function __construct($parameters){} + abstract public function __construct($parameters); abstract public function mkdir($path); abstract public function rmdir($path); abstract public function opendir($path); diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index ba78fca80e5..fd389d3e2d7 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -220,7 +220,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { } $tmpFile=OC_Helper::tmpFile($extension); $target=fopen($tmpFile,'w'); - $count=OC_Helper::streamCopy($source,$target); + OC_Helper::streamCopy($source,$target); return $tmpFile; } // abstract public function touch($path, $mtime=null); diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index b2eba051515..d60f32b15be 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -4,7 +4,6 @@ */ class OC_Filestorage_Local extends OC_Filestorage_Common{ protected $datadir; - private static $mimetypes=null; public function __construct($arguments){ $this->datadir=$arguments['datadir']; if(substr($this->datadir,-1)!=='/'){ @@ -41,7 +40,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ } public function filesize($path){ if($this->is_dir($path)){ - return $this->getFolderSize($path); + return 0; }else{ return filesize($this->datadir.$path); } @@ -157,7 +156,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ return $return; } - public function hash($type,$path,$raw){ + public function hash($path,$type,$raw=false){ return hash_file($type,$this->datadir.$path,$raw); } @@ -187,15 +186,6 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ } /** - * @brief get the size of folder and it's content - * @param string $path file path - * @return int size of folder and it's content - */ - public function getFolderSize($path){ - return 0;//depricated, use OC_FileCach instead - } - - /** * check if a file or folder has been updated since $time * @param int $time * @return bool diff --git a/lib/filesystem.php b/lib/filesystem.php index 65318fa3ab6..ec30ffb8f4c 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -46,9 +46,10 @@ class OC_Filesystem{ static private $storages=array(); static private $mounts=array(); - static private $storageTypes=array(); public static $loaded=false; - private $fakeRoot=''; + /** + * @var OC_Filestorage $defaultInstance + */ static private $defaultInstance; @@ -155,7 +156,8 @@ class OC_Filesystem{ } $path=str_replace('//', '/',$path); $foundMountPoint=''; - foreach(OC_Filesystem::$mounts as $mountpoint=>$storage){ + $mountPoints=array_keys(OC_Filesystem::$mounts); + foreach($mountPoints as $mountpoint){ if($mountpoint==$path){ return $mountpoint; } @@ -260,10 +262,7 @@ class OC_Filesystem{ * tear down the filesystem, removing all storage providers */ static public function tearDown(){ - foreach(self::$storages as $mountpoint=>$storage){ - unset(self::$storages[$mountpoint]); - } - $fakeRoot=''; + self::$storages=array(); } /** @@ -287,7 +286,7 @@ class OC_Filesystem{ * @return bool */ static public function chroot($fakeRoot){ - return self::$defaultInstance->chroot($path); + return self::$defaultInstance->chroot($fakeRoot); } /** @@ -320,22 +319,8 @@ class OC_Filesystem{ if(substr($mountpoint,-1)!=='/'){ $mountpoint=$mountpoint.'/'; } - if (self::getView() != null && $mountpoint != '/' && !self::is_dir(basename($mountpoint))) { - self::mkdir(basename($mountpoint)); - } self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments); } - - /** - * create all storage backends mounted in the filesystem - */ - static private function mountAll(){ - foreach(self::$mounts as $mountPoint=>$mount){ - if(!isset(self::$storages[$mountPoint])){ - self::$storages[$mountPoint]=self::createStorage($mount['type'],$mount['arguments']); - } - } - } /** * return the path to a local version of the file @@ -485,9 +470,17 @@ class OC_Filesystem{ * @return bool */ static public function hasUpdated($path,$time){ - return self::$defaultInstance->hasUpdated($path); + return self::$defaultInstance->hasUpdated($path,$time); + } + + static public function removeETagHook($params) { + $path=$params['path']; + OC_Connector_Sabre_Node::removeETagPropertyForFile($path); } } +OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook'); +OC_Hook::connect('OC_Filesystem','post_delete','OC_Filesystem','removeETagHook'); +OC_Hook::connect('OC_Filesystem','post_rename','OC_Filesystem','removeETagHook'); OC_Util::setupFS(); require_once('filecache.php'); diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 448663bb081..a23d7bbe7fd 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -393,7 +393,7 @@ class OC_FilesystemView { return $this->basicOperation('getMimeType',$path); } public function hash($type,$path){ - return $this->basicOperation('hash',$path,array('read')); + return $this->basicOperation('hash',$path,array('read'),$type); } public function free_space($path='/'){ diff --git a/lib/group/database.php b/lib/group/database.php index fb173665eb8..2770ec185c4 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -41,7 +41,6 @@ * Class for group management in a SQL Database (e.g. MySQL, SQLite) */ class OC_Group_Database extends OC_Group_Backend { - private $userGroupCache=array(); /** * @brief Try to create a new group @@ -116,7 +115,7 @@ class OC_Group_Database extends OC_Group_Backend { // No duplicate entries! if( !$this->inGroup( $uid, $gid )){ $query = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" ); - $result = $query->execute( array( $uid, $gid )); + $query->execute( array( $uid, $gid )); return true; }else{ return false; @@ -133,7 +132,7 @@ class OC_Group_Database extends OC_Group_Backend { */ public function removeFromGroup( $uid, $gid ){ $query = OC_DB::prepare( "DELETE FROM *PREFIX*group_user WHERE uid = ? AND gid = ?" ); - $result = $query->execute( array( $uid, $gid )); + $query->execute( array( $uid, $gid )); return true; } diff --git a/lib/group/dummy.php b/lib/group/dummy.php index 0825b10708a..1243891023f 100644 --- a/lib/group/dummy.php +++ b/lib/group/dummy.php @@ -126,7 +126,8 @@ class OC_Group_Dummy extends OC_Group_Backend { */ public function getUserGroups($uid){ $groups=array(); - foreach($this->groups as $group=>$user){ + $allGroups=array_keys($this->groups); + foreach($allGroups as $group){ if($this->inGroup($uid,$group)){ $groups[]=$group; } diff --git a/lib/group/example.php b/lib/group/example.php index c18562db7a4..9c9ece5ac77 100644 --- a/lib/group/example.php +++ b/lib/group/example.php @@ -34,7 +34,7 @@ abstract class OC_Group_Example { * Trys to create a new group. If the group name already exists, false will * be returned. */ - public static function createGroup($gid){} + abstract public static function createGroup($gid); /** * @brief delete a group @@ -43,7 +43,7 @@ abstract class OC_Group_Example { * * Deletes a group and removes it from the group_user-table */ - public static function deleteGroup($gid){} + abstract public static function deleteGroup($gid); /** * @brief is user in group? @@ -53,7 +53,7 @@ abstract class OC_Group_Example { * * Checks whether the user is member of a group or not. */ - public static function inGroup($uid, $gid){} + abstract public static function inGroup($uid, $gid); /** * @brief Add a user to a group @@ -63,7 +63,7 @@ abstract class OC_Group_Example { * * Adds a user to a group. */ - public static function addToGroup($uid, $gid){} + abstract public static function addToGroup($uid, $gid); /** * @brief Removes a user from a group @@ -73,7 +73,7 @@ abstract class OC_Group_Example { * * removes the user from a group. */ - public static function removeFromGroup($uid,$gid){} + abstract public static function removeFromGroup($uid,$gid); /** * @brief Get all groups a user belongs to @@ -83,7 +83,7 @@ abstract class OC_Group_Example { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ - public static function getUserGroups($uid){} + abstract public static function getUserGroups($uid); /** * @brief get a list of all groups @@ -91,19 +91,19 @@ abstract class OC_Group_Example { * * Returns a list with all groups */ - public static function getGroups(){} + abstract public static function getGroups(); /** * check if a group exists * @param string $gid * @return bool */ - public function groupExists($gid){} + abstract public function groupExists($gid); /** * @brief get a list of all users in a group * @returns array with user ids */ - public static function usersInGroup($gid){} + abstract public static function usersInGroup($gid); } diff --git a/lib/helper.php b/lib/helper.php index 0d18098a4e7..c4f7e8b2e19 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -676,10 +676,10 @@ class OC_Helper { */ public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { $offset = -1; - $length = mb_strlen($search, 'UTF-8'); - while(($i = mb_strrpos($subject, $search, $offset, 'UTF-8'))) { + $length = mb_strlen($search, $encoding); + while(($i = mb_strrpos($subject, $search, $offset, $encoding))) { $subject = OC_Helper::mb_substr_replace($subject, $replace, $i, $length); - $offset = $i - mb_strlen($subject, 'UTF-8') - 1; + $offset = $i - mb_strlen($subject, $encoding) - 1; $count++; } return $subject; diff --git a/lib/image.php b/lib/image.php index 01e843d8316..c438b3d67f6 100644 --- a/lib/image.php +++ b/lib/image.php @@ -24,8 +24,8 @@ //From user comments at http://dk2.php.net/manual/en/function.exif-imagetype.php if ( ! function_exists( 'exif_imagetype' ) ) { function exif_imagetype ( $filename ) { - if ( ( list($width, $height, $type, $attr) = getimagesize( $filename ) ) !== false ) { - return $type; + if ( ( $info = getimagesize( $filename ) ) !== false ) { + return $info[2]; } return false; } @@ -364,7 +364,7 @@ class OC_Image { public function load($imageref) { if(is_resource($imageref)) { if(get_resource_type($imageref) == 'gd') { - $this->resource = $res; + $this->resource = $imageref; return $this->resource; } elseif(in_array(get_resource_type($imageref), array('file','stream'))) { return $this->loadFromFileHandle($imageref); @@ -650,9 +650,6 @@ class OC_Image { OC_Log::write('core',__METHOD__.'(): No image loaded', OC_Log::ERROR); return false; } - $width_orig=imageSX($this->resource); - $height_orig=imageSY($this->resource); - //OC_Log::write('core',__METHOD__.'(): Original size: '.$width_orig.'x'.$height_orig, OC_Log::DEBUG); $process = imagecreatetruecolor($w, $h); if ($process == false) { OC_Log::write('core',__METHOD__.'(): Error creating true color image',OC_Log::ERROR); diff --git a/lib/migrate.php b/lib/migrate.php index f788a637d3c..1b6367ed6ec 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -91,7 +91,7 @@ class OC_Migrate{ if( self::$exporttype == 'user' ){ // Check user exists if( !is_null($uid) ){ - $db = new OC_User_Database; + $db = new OC_User_Database; if( !$db->userExists( $uid ) ){ OC_Log::write('migration', 'User: '.$uid.' is not in the database and so cannot be exported.', OC_Log::ERROR); return json_encode( array( 'success' => false ) ); diff --git a/lib/ocs.php b/lib/ocs.php index 1be41202d78..77dd437d6c6 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -88,7 +88,6 @@ class OC_OCS { $method='get'; }elseif($_SERVER['REQUEST_METHOD'] == 'PUT') { $method='put'; - parse_str(file_get_contents("php://input"),$put_vars); }elseif($_SERVER['REQUEST_METHOD'] == 'POST') { $method='post'; }else{ @@ -356,9 +355,6 @@ class OC_OCS { * @return string xml/json */ private static function apiConfig($format) { - $user=OC_OCS::checkpassword(false); - $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'],0,-11).''; - $xml['version']='1.5'; $xml['website']='ownCloud'; $xml['host']=OCP\Util::getServerHost(); @@ -416,7 +412,7 @@ class OC_OCS { */ private static function activityPut($format,$message) { // not implemented in ownCloud - $user=OC_OCS::checkpassword(); + OC_OCS::checkpassword(); echo(OC_OCS::generatexml($format,'ok',100,'')); } diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 951d761d7e6..ae35470cff6 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -71,7 +71,7 @@ class OC_OCSClient{ $tmp=$data->data; $cats=array(); - foreach($tmp->category as $key=>$value) { + foreach($tmp->category as $value) { $id= (int) $value->id; $name= (string) $value->name; diff --git a/lib/preferences.php b/lib/preferences.php index f72378ce94f..c91423e69bc 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -165,7 +165,7 @@ class OC_Preferences{ public static function deleteKey( $user, $app, $key ){ // No need for more comments $query = OC_DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' ); - $result = $query->execute( array( $user, $app, $key )); + $query->execute( array( $user, $app, $key )); return true; } @@ -181,7 +181,7 @@ class OC_Preferences{ public static function deleteApp( $user, $app ){ // No need for more comments $query = OC_DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE userid = ? AND appid = ?' ); - $result = $query->execute( array( $user, $app )); + $query->execute( array( $user, $app )); return true; } @@ -196,7 +196,7 @@ class OC_Preferences{ public static function deleteUser( $user ){ // No need for more comments $query = OC_DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE userid = ?' ); - $result = $query->execute( array( $user )); + $query->execute( array( $user )); return true; } @@ -211,7 +211,7 @@ class OC_Preferences{ public static function deleteAppFromAllUsers( $app ){ // No need for more comments $query = OC_DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE appid = ?' ); - $result = $query->execute( array( $app )); + $query->execute( array( $app )); return true; } diff --git a/lib/public/app.php b/lib/public/app.php index 38c51af9cdb..28411933beb 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -34,28 +34,6 @@ namespace OCP; * This class provides functions to manage apps in ownCloud */ class App { - - /** - * @brief Makes owncloud aware of this app - * @brief This call is deprecated and not necessary to use. - * @param $data array with all information - * @returns true/false - * - * This function registers the application. $data is an associative array. - * The following keys are required: - * - id: id of the application, has to be unique ('addressbook') - * - name: Human readable name ('Addressbook') - * - version: array with Version (major, minor, bugfix) ( array(1, 0, 2)) - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * a list of applications. Lower values come first. - * - */ - public static function register( $data ){ - } - - /** * @brief adds an entry to the navigation * @param $data array containing the data diff --git a/lib/public/json.php b/lib/public/json.php index 1bc1e3ab4d5..99df79173eb 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -35,70 +35,137 @@ namespace OCP; */ class JSON { - /** * @brief Encode and print $data in JSON format * @param array $data The data to use * @param string $setContentType the optional content type + * @return string json formatted string. */ public static function encodedPrint( $data, $setContentType=true ){ return(\OC_JSON::encodedPrint( $data, $setContentType )); } - /** - * @brief Check if the user is logged in, send json error msg if not + * Check if the user is logged in, send json error msg if not. + * + * This method checks if a user is logged in. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Authentication error."}} + * + * Add this call to the start of all ajax method files that requires + * an authenticated user. + * + * @return string json formatted error string if not authenticated. */ public static function checkLoggedIn(){ return(\OC_JSON::checkLoggedIn()); } /** - * @brief Check an ajax get/post call if the request token is valid. - * @return json Error msg if not valid. - */ + * Check an ajax get/post call if the request token is valid. + * + * This method checks for a valid variable 'requesttoken' in $_GET, + * $_POST and $_SERVER. If a valid token is not found, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Token expired. Please reload page."}} + * + * Add this call to the start of all ajax method files that creates, + * updates or deletes anything. + * In cases where you e.g. use an ajax call to load a dialog containing + * a submittable form, you will need to add the requesttoken first as a + * parameter to the ajax call, then assign it to the template and finally + * add a hidden input field also named 'requesttoken' containing the value. + * + * @return string json formatted error string if not valid. + */ public static function callCheck(){ return(\OC_JSON::callCheck()); } /** - * @brief Send json success msg + * Send json success msg + * + * Return a json success message with optional extra data. + * @see OCP\JSON::error() for the format to use. + * * @param array $data The data to use + * @return string json formatted string. */ public static function success( $data = array() ){ return(\OC_JSON::success( $data )); } - /** - * @brief Send json error msg + * Send json error msg + * + * Return a json error message with optional extra data for + * error message or app specific data. + * + * Example use: + * + * $id = [some value] + * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); + * + * Will return the json formatted string: + * + * {"status":"error","data":{"message":"An error happened", "id":[some value]}} + * * @param array $data The data to use + * @return string json formatted error string. */ public static function error( $data = array() ){ return(\OC_JSON::error( $data )); } - /** - * @brief set Content-Type header to jsonrequest - * @param array $type The contwnt type header - */ + * @brief set Content-Type header to jsonrequest + * @param array $type The contwnt type header + * @return string json formatted string. + */ public static function setContentTypeHeader( $type='application/json' ){ return(\OC_JSON::setContentTypeHeader( $type )); } - /** - * @brief Check if the App is enabled and send JSON error message instead - * @param string $app The app to check - */ + * Check if the App is enabled and send JSON error message instead + * + * This method checks if a specific app is enabled. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Application is not enabled."}} + * + * Add this call to the start of all ajax method files that requires + * a specific app to be enabled. + * + * @param string $app The app to check + * @return string json formatted string if not enabled. + */ public static function checkAppEnabled( $app ){ return(\OC_JSON::checkAppEnabled( $app )); } - /** - * @brief Check if the user is a admin, send json error msg if not + * Check if the user is a admin, send json error msg if not + * + * This method checks if the current user has admin rights. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Authentication error."}} + * + * Add this call to the start of all ajax method files that requires + * administrative rights. + * + * @return string json formatted string if not admin user. */ public static function checkAdminUser(){ return(\OC_JSON::checkAdminUser()); diff --git a/lib/search/provider.php b/lib/search/provider.php index 838ab696d04..b3ee79b4770 100644 --- a/lib/search/provider.php +++ b/lib/search/provider.php @@ -2,13 +2,17 @@ /** * provides search functionalty */ -class OC_Search_Provider { - public function __construct($options){} +abstract class OC_Search_Provider { + private $options; + + public function __construct($options){ + $this->options=$options; + } /** * search for $query * @param string $query * @return array An array of OC_Search_Result's */ - public function search($query){} + abstract public function search($query); } diff --git a/lib/setup.php b/lib/setup.php index 027c84db092..4d71bed86e2 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -102,7 +102,6 @@ class OC_Setup { } else { $oldUser=OC_Config::getValue('dbuser', false); - $oldPassword=OC_Config::getValue('dbpassword', false); $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql if(mysql_query($query, $connection)) { diff --git a/lib/streamwrappers.php b/lib/streamwrappers.php index f1e0fa0e1d9..f502c6170bd 100644 --- a/lib/streamwrappers.php +++ b/lib/streamwrappers.php @@ -1,6 +1,4 @@ <?php -global $FAKEDIRS; -$FAKEDIRS=array(); class OC_FakeDirStream{ public static $dirs=array(); @@ -8,8 +6,6 @@ class OC_FakeDirStream{ private $index; public function dir_opendir($path,$options){ - global $FAKEDIRS; - $url=parse_url($path); $this->name=substr($path,strlen('fakedir://')); $this->index=0; if(!isset(self::$dirs[$this->name])){ @@ -161,7 +157,6 @@ class OC_StaticStreamWrapper { public function stream_write($data) { if (!$this->writable) return 0; $size = strlen($data); - $len = strlen(self::$data[$this->path]); if ($this->stream_eof()) { self::$data[$this->path] .= $data; } else { diff --git a/lib/template.php b/lib/template.php index 3b48c27b9b4..5b6999af533 100644 --- a/lib/template.php +++ b/lib/template.php @@ -82,7 +82,6 @@ function relative_modified_date($timestamp) { $diffhours = round($diffminutes/60); $diffdays = round($diffhours/24); $diffmonths = round($diffdays/31); - $diffyears = round($diffdays/365); if($timediff < 60) { return $l->t('seconds ago'); } else if($timediff < 120) { return $l->t('1 minute ago'); } diff --git a/lib/templatelayout.php b/lib/templatelayout.php index d33a87e9e4c..588a7845997 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -123,7 +123,7 @@ class OC_TemplateLayout extends OC_Template { elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) { $append =true; break; } } if(! $append) { - echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } } diff --git a/lib/user/database.php b/lib/user/database.php index a48b8357d64..cc27b3ddbfd 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -39,7 +39,6 @@ require_once 'phpass/PasswordHash.php'; * Class for user management in a SQL Database (e.g. MySQL, SQLite) */ class OC_User_Database extends OC_User_Backend { - static private $userGroupCache=array(); /** * @var PasswordHash */ @@ -87,7 +86,7 @@ class OC_User_Database extends OC_User_Backend { public function deleteUser( $uid ){ // Delete user-group-relation $query = OC_DB::prepare( "DELETE FROM `*PREFIX*users` WHERE uid = ?" ); - $result = $query->execute( array( $uid )); + $query->execute( array( $uid )); return true; } @@ -104,11 +103,10 @@ class OC_User_Database extends OC_User_Backend { $hasher=$this->getHasher(); $hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', '')); $query = OC_DB::prepare( "UPDATE *PREFIX*users SET password = ? WHERE uid = ?" ); - $result = $query->execute( array( $hash, $uid )); + $query->execute( array( $hash, $uid )); return true; - } - else{ + }else{ return false; } } diff --git a/lib/user/example.php b/lib/user/example.php index 7f3fd1b8578..77246d8136c 100644 --- a/lib/user/example.php +++ b/lib/user/example.php @@ -35,9 +35,7 @@ abstract class OC_User_Example extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser($uid, $password){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } + abstract public function createUser($uid, $password); /** * @brief Set password @@ -47,9 +45,7 @@ abstract class OC_User_Example extends OC_User_Backend { * * Change the password of a user */ - public function setPassword($uid, $password){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } + abstract public function setPassword($uid, $password); /** * @brief Check if the password is correct @@ -60,7 +56,5 @@ abstract class OC_User_Example extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword($uid, $password){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } + abstract public function checkPassword($uid, $password); } diff --git a/lib/util.php b/lib/util.php index 2eb102dfa69..f1a87742168 100755 --- a/lib/util.php +++ b/lib/util.php @@ -189,8 +189,6 @@ class OC_Util { if(!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')){ $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>','hint'=>'');//TODO: sane hint } - $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); - $CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" ); //common hint for all file permissons error messages $permissionsHint="Permissions can usually be fixed by giving the webserver write access to the ownCloud directory"; diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 54e60e6569d..c33c513fcff 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -30,8 +30,10 @@ class Test_Cache_File extends Test_Cache { OC_FileProxy::clearProxies(); OC_Hook::clear('OC_Filesystem'); - //enable only the encryption hook - OC_FileProxy::register(new OC_FileProxy_Encryption()); + //enable only the encryption hook if needed + if(OC_App::isEnabled('files_encryption')){ + OC_FileProxy::register(new OC_FileProxy_Encryption()); + } //set up temporary storage OC_Filesystem::clearMounts(); diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php index b2fcce93c5b..f484ffa78f7 100644 --- a/tests/lib/user/database.php +++ b/tests/lib/user/database.php @@ -21,7 +21,6 @@ */ class Test_User_Database extends Test_User_Backend { - private $user=array(); /** * get a new unique user name * test cases can override this in order to clean up created user |