summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-07 17:47:54 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-07 17:47:54 +0200
commit5e397d89c4152aee48692b1d302f1f11b16838b3 (patch)
tree1f9e20c9ad153b3d1dd2ad077c1f97a8da8a7815 /lib
parenta2301e8b6975a213f05468f171229f7a1986a377 (diff)
parenta3d0e29aa5df3390929c6378bd4f9c6bbf25c473 (diff)
downloadnextcloud-server-5e397d89c4152aee48692b1d302f1f11b16838b3.tar.gz
nextcloud-server-5e397d89c4152aee48692b1d302f1f11b16838b3.zip
Merge branch 'master' into fixing-4546-master
Conflicts: lib/private/connector/sabre/directory.php
Diffstat (limited to 'lib')
-rw-r--r--lib/apphelper.php25
-rw-r--r--lib/autoloader.php11
-rw-r--r--lib/base.php48
-rw-r--r--lib/cache/fileglobalgc.php8
-rw-r--r--lib/l10n/ar.php4
-rw-r--r--lib/l10n/bg_BG.php4
-rw-r--r--lib/l10n/ca.php4
-rw-r--r--lib/l10n/cs_CZ.php4
-rw-r--r--lib/l10n/cy_GB.php4
-rw-r--r--lib/l10n/da.php4
-rw-r--r--lib/l10n/de.php4
-rw-r--r--lib/l10n/de_CH.php4
-rw-r--r--lib/l10n/de_DE.php4
-rw-r--r--lib/l10n/el.php4
-rw-r--r--lib/l10n/en_GB.php4
-rw-r--r--lib/l10n/eo.php4
-rw-r--r--lib/l10n/es.php7
-rw-r--r--lib/l10n/es_AR.php4
-rw-r--r--lib/l10n/et_EE.php4
-rw-r--r--lib/l10n/eu.php4
-rw-r--r--lib/l10n/fa.php4
-rw-r--r--lib/l10n/fi_FI.php4
-rw-r--r--lib/l10n/fr.php4
-rw-r--r--lib/l10n/gl.php4
-rw-r--r--lib/l10n/he.php4
-rw-r--r--lib/l10n/hu_HU.php11
-rw-r--r--lib/l10n/id.php4
-rw-r--r--lib/l10n/is.php4
-rw-r--r--lib/l10n/it.php4
-rw-r--r--lib/l10n/ja_JP.php4
-rw-r--r--lib/l10n/ka_GE.php4
-rw-r--r--lib/l10n/ko.php8
-rw-r--r--lib/l10n/lt_LT.php4
-rw-r--r--lib/l10n/lv.php4
-rw-r--r--lib/l10n/mk.php4
-rw-r--r--lib/l10n/my_MM.php4
-rw-r--r--lib/l10n/nb_NO.php4
-rw-r--r--lib/l10n/nl.php4
-rw-r--r--lib/l10n/pl.php7
-rw-r--r--lib/l10n/pt_BR.php4
-rw-r--r--lib/l10n/pt_PT.php4
-rw-r--r--lib/l10n/ro.php4
-rw-r--r--lib/l10n/ru.php4
-rw-r--r--lib/l10n/sk_SK.php4
-rw-r--r--lib/l10n/sl.php4
-rw-r--r--lib/l10n/sq.php4
-rw-r--r--lib/l10n/sr.php4
-rw-r--r--lib/l10n/sv.php4
-rw-r--r--lib/l10n/ta_LK.php4
-rw-r--r--lib/l10n/th_TH.php4
-rw-r--r--lib/l10n/tr.php4
-rw-r--r--lib/l10n/uk.php4
-rw-r--r--lib/l10n/vi.php4
-rw-r--r--lib/l10n/zh_CN.php4
-rw-r--r--lib/l10n/zh_TW.php7
-rw-r--r--lib/private/allconfig.php77
-rw-r--r--lib/private/api.php (renamed from lib/api.php)0
-rw-r--r--lib/private/app.php (renamed from lib/app.php)31
-rw-r--r--lib/private/appconfig.php (renamed from lib/appconfig.php)0
-rw-r--r--lib/private/appframework/app.php98
-rw-r--r--lib/private/appframework/controller/controller.php142
-rw-r--r--lib/private/appframework/core/api.php348
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php146
-rw-r--r--lib/private/appframework/http/dispatcher.php100
-rw-r--r--lib/private/appframework/http/downloadresponse.php50
-rw-r--r--lib/private/appframework/http/http.php148
-rw-r--r--lib/private/appframework/http/redirectresponse.php56
-rw-r--r--lib/private/appframework/http/request.php389
-rw-r--r--lib/private/appframework/middleware/middlewaredispatcher.php159
-rw-r--r--lib/private/appframework/middleware/security/securityexception.php41
-rw-r--r--lib/private/appframework/middleware/security/securitymiddleware.php136
-rw-r--r--lib/private/appframework/routing/routeactionhandler.php42
-rw-r--r--lib/private/appframework/routing/routeconfig.php186
-rw-r--r--lib/private/appframework/utility/methodannotationreader.php61
-rw-r--r--lib/private/appframework/utility/simplecontainer.php44
-rw-r--r--lib/private/appframework/utility/timefactory.php42
-rw-r--r--lib/private/archive.php (renamed from lib/archive.php)0
-rw-r--r--lib/private/archive/tar.php (renamed from lib/archive/tar.php)0
-rw-r--r--lib/private/archive/zip.php (renamed from lib/archive/zip.php)0
-rw-r--r--lib/private/arrayparser.php (renamed from lib/arrayparser.php)0
-rw-r--r--lib/private/avatar.php (renamed from lib/avatar.php)0
-rw-r--r--lib/private/backgroundjob.php (renamed from lib/backgroundjob.php)0
-rw-r--r--lib/private/backgroundjob/job.php (renamed from lib/backgroundjob/job.php)0
-rw-r--r--lib/private/backgroundjob/joblist.php (renamed from lib/backgroundjob/joblist.php)0
-rw-r--r--lib/private/backgroundjob/legacy/queuedjob.php (renamed from lib/backgroundjob/legacy/queuedjob.php)0
-rw-r--r--lib/private/backgroundjob/legacy/regularjob.php (renamed from lib/backgroundjob/legacy/regularjob.php)0
-rw-r--r--lib/private/backgroundjob/queuedjob.php (renamed from lib/backgroundjob/queuedjob.php)0
-rw-r--r--lib/private/backgroundjob/timedjob.php (renamed from lib/backgroundjob/timedjob.php)0
-rw-r--r--lib/private/cache.php (renamed from lib/cache.php)23
-rw-r--r--lib/private/cache/broker.php (renamed from lib/cache/broker.php)12
-rw-r--r--lib/private/cache/file.php (renamed from lib/cache/file.php)13
-rw-r--r--lib/private/cache/fileglobal.php (renamed from lib/cache/fileglobal.php)9
-rw-r--r--lib/private/cache/fileglobalgc.php9
-rw-r--r--lib/private/cache/usercache.php77
-rw-r--r--lib/private/config.php (renamed from lib/config.php)2
-rw-r--r--lib/private/connector/sabre/ServiceUnavailable.php (renamed from lib/connector/sabre/ServiceUnavailable.php)0
-rw-r--r--lib/private/connector/sabre/aborteduploaddetectionplugin.php (renamed from lib/connector/sabre/aborteduploaddetectionplugin.php)6
-rw-r--r--lib/private/connector/sabre/auth.php (renamed from lib/connector/sabre/auth.php)5
-rw-r--r--lib/private/connector/sabre/directory.php (renamed from lib/connector/sabre/directory.php)63
-rw-r--r--lib/private/connector/sabre/file.php (renamed from lib/connector/sabre/file.php)66
-rw-r--r--lib/private/connector/sabre/locks.php (renamed from lib/connector/sabre/locks.php)0
-rw-r--r--lib/private/connector/sabre/maintenanceplugin.php (renamed from lib/connector/sabre/maintenanceplugin.php)0
-rw-r--r--lib/private/connector/sabre/node.php (renamed from lib/connector/sabre/node.php)26
-rw-r--r--lib/private/connector/sabre/objecttree.php (renamed from lib/connector/sabre/objecttree.php)0
-rw-r--r--lib/private/connector/sabre/principal.php (renamed from lib/connector/sabre/principal.php)0
-rw-r--r--lib/private/connector/sabre/quotaplugin.php (renamed from lib/connector/sabre/quotaplugin.php)0
-rw-r--r--lib/private/connector/sabre/request.php (renamed from lib/connector/sabre/request.php)0
-rw-r--r--lib/private/contactsmanager.php145
-rw-r--r--lib/private/db.php (renamed from lib/db.php)0
-rw-r--r--lib/private/db/adapter.php (renamed from lib/db/adapter.php)0
-rw-r--r--lib/private/db/adapteroci8.php (renamed from lib/db/adapteroci8.php)0
-rw-r--r--lib/private/db/adapterpgsql.php (renamed from lib/db/adapterpgsql.php)0
-rw-r--r--lib/private/db/adaptersqlite.php (renamed from lib/db/adaptersqlite.php)0
-rw-r--r--lib/private/db/adaptersqlsrv.php (renamed from lib/db/adaptersqlsrv.php)0
-rw-r--r--lib/private/db/connection.php (renamed from lib/db/connection.php)2
-rw-r--r--lib/private/db/mdb2schemamanager.php (renamed from lib/db/mdb2schemamanager.php)0
-rw-r--r--lib/private/db/mdb2schemareader.php (renamed from lib/db/mdb2schemareader.php)0
-rw-r--r--lib/private/db/mdb2schemawriter.php (renamed from lib/db/mdb2schemawriter.php)0
-rw-r--r--lib/private/db/oracleconnection.php (renamed from lib/db/oracleconnection.php)0
-rw-r--r--lib/private/db/statementwrapper.php (renamed from lib/db/statementwrapper.php)0
-rw-r--r--lib/private/defaults.php (renamed from lib/defaults.php)5
-rw-r--r--lib/private/eventsource.php (renamed from lib/eventsource.php)0
-rw-r--r--lib/private/filechunking.php (renamed from lib/filechunking.php)2
-rw-r--r--lib/private/fileproxy.php (renamed from lib/fileproxy.php)0
-rw-r--r--lib/private/fileproxy/fileoperations.php (renamed from lib/fileproxy/fileoperations.php)0
-rw-r--r--lib/private/files.php (renamed from lib/files.php)0
-rw-r--r--lib/private/files/cache/backgroundwatcher.php (renamed from lib/files/cache/backgroundwatcher.php)0
-rw-r--r--lib/private/files/cache/cache.php (renamed from lib/files/cache/cache.php)47
-rw-r--r--lib/private/files/cache/legacy.php (renamed from lib/files/cache/legacy.php)0
-rw-r--r--lib/private/files/cache/permissions.php (renamed from lib/files/cache/permissions.php)0
-rw-r--r--lib/private/files/cache/scanner.php (renamed from lib/files/cache/scanner.php)0
-rw-r--r--lib/private/files/cache/storage.php (renamed from lib/files/cache/storage.php)0
-rw-r--r--lib/private/files/cache/updater.php (renamed from lib/files/cache/updater.php)0
-rw-r--r--lib/private/files/cache/upgrade.php (renamed from lib/files/cache/upgrade.php)10
-rw-r--r--lib/private/files/cache/watcher.php (renamed from lib/files/cache/watcher.php)0
-rw-r--r--lib/private/files/filesystem.php (renamed from lib/files/filesystem.php)0
-rw-r--r--lib/private/files/mapper.php (renamed from lib/files/mapper.php)0
-rw-r--r--lib/private/files/mount/manager.php (renamed from lib/files/mount/manager.php)0
-rw-r--r--lib/private/files/mount/mount.php (renamed from lib/files/mount/mount.php)0
-rw-r--r--lib/private/files/node/file.php (renamed from lib/files/node/file.php)0
-rw-r--r--lib/private/files/node/folder.php (renamed from lib/files/node/folder.php)0
-rw-r--r--lib/private/files/node/node.php (renamed from lib/files/node/node.php)0
-rw-r--r--lib/private/files/node/nonexistingfile.php (renamed from lib/files/node/nonexistingfile.php)0
-rw-r--r--lib/private/files/node/nonexistingfolder.php (renamed from lib/files/node/nonexistingfolder.php)0
-rw-r--r--lib/private/files/node/root.php (renamed from lib/files/node/root.php)0
-rw-r--r--lib/private/files/storage/common.php (renamed from lib/files/storage/common.php)0
-rw-r--r--lib/private/files/storage/commontest.php (renamed from lib/files/storage/commontest.php)0
-rw-r--r--lib/private/files/storage/loader.php (renamed from lib/files/storage/loader.php)0
-rw-r--r--lib/private/files/storage/local.php (renamed from lib/files/storage/local.php)0
-rw-r--r--lib/private/files/storage/mappedlocal.php (renamed from lib/files/storage/mappedlocal.php)0
-rw-r--r--lib/private/files/storage/storage.php (renamed from lib/files/storage/storage.php)0
-rw-r--r--lib/private/files/storage/temporary.php (renamed from lib/files/storage/temporary.php)0
-rw-r--r--lib/private/files/storage/wrapper/quota.php (renamed from lib/files/storage/wrapper/quota.php)0
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php (renamed from lib/files/storage/wrapper/wrapper.php)0
-rw-r--r--lib/private/files/stream/close.php (renamed from lib/files/stream/close.php)0
-rw-r--r--lib/private/files/stream/dir.php (renamed from lib/files/stream/dir.php)0
-rw-r--r--lib/private/files/stream/oc.php (renamed from lib/files/stream/oc.php)0
-rw-r--r--lib/private/files/stream/quota.php (renamed from lib/files/stream/quota.php)0
-rw-r--r--lib/private/files/stream/staticstream.php (renamed from lib/files/stream/staticstream.php)0
-rw-r--r--lib/private/files/type/detection.php (renamed from lib/files/type/detection.php)0
-rw-r--r--lib/private/files/type/templatemanager.php (renamed from lib/files/type/templatemanager.php)0
-rw-r--r--lib/private/files/utils/scanner.php (renamed from lib/files/utils/scanner.php)0
-rw-r--r--lib/private/files/view.php (renamed from lib/files/view.php)0
-rw-r--r--lib/private/geo.php (renamed from lib/geo.php)0
-rw-r--r--lib/private/group.php (renamed from lib/group.php)0
-rw-r--r--lib/private/group/backend.php (renamed from lib/group/backend.php)0
-rw-r--r--lib/private/group/database.php (renamed from lib/group/database.php)0
-rw-r--r--lib/private/group/dummy.php (renamed from lib/group/dummy.php)0
-rw-r--r--lib/private/group/example.php (renamed from lib/group/example.php)0
-rw-r--r--lib/private/group/group.php (renamed from lib/group/group.php)0
-rw-r--r--lib/private/group/interface.php (renamed from lib/group/interface.php)0
-rw-r--r--lib/private/group/manager.php (renamed from lib/group/manager.php)0
-rw-r--r--lib/private/helper.php (renamed from lib/helper.php)52
-rw-r--r--lib/private/hintexception.php (renamed from lib/hintexception.php)0
-rw-r--r--lib/private/hook.php (renamed from lib/hook.php)0
-rw-r--r--lib/private/hooks/basicemitter.php (renamed from lib/hooks/basicemitter.php)0
-rw-r--r--lib/private/hooks/emitter.php (renamed from lib/hooks/emitter.php)0
-rw-r--r--lib/private/hooks/forwardingemitter.php (renamed from lib/hooks/forwardingemitter.php)0
-rw-r--r--lib/private/hooks/legacyemitter.php (renamed from lib/hooks/legacyemitter.php)0
-rw-r--r--lib/private/hooks/publicemitter.php (renamed from lib/hooks/publicemitter.php)0
-rw-r--r--lib/private/image.php (renamed from lib/image.php)0
-rw-r--r--lib/private/installer.php (renamed from lib/installer.php)0
-rw-r--r--lib/private/json.php (renamed from lib/json.php)0
-rw-r--r--lib/private/l10n.php (renamed from lib/l10n.php)18
-rw-r--r--lib/private/l10n/factory.php34
-rw-r--r--lib/private/l10n/string.php (renamed from lib/l10n/string.php)0
-rw-r--r--lib/private/legacy/cache.php10
-rw-r--r--lib/private/legacy/cache/fileglobalgc.php4
-rw-r--r--lib/private/legacy/config.php (renamed from lib/legacy/config.php)0
-rw-r--r--lib/private/legacy/filesystem.php (renamed from lib/legacy/filesystem.php)0
-rw-r--r--lib/private/legacy/filesystemview.php (renamed from lib/legacy/filesystemview.php)0
-rw-r--r--lib/private/legacy/log.php (renamed from lib/legacy/log.php)0
-rw-r--r--lib/private/legacy/preferences.php (renamed from lib/legacy/preferences.php)0
-rw-r--r--lib/private/legacy/updater.php (renamed from lib/legacy/updater.php)0
-rw-r--r--lib/private/log.php (renamed from lib/log.php)0
-rw-r--r--lib/private/log/errorhandler.php (renamed from lib/log/errorhandler.php)0
-rw-r--r--lib/private/log/owncloud.php (renamed from lib/log/owncloud.php)0
-rw-r--r--lib/private/log/rotate.php (renamed from lib/log/rotate.php)0
-rw-r--r--lib/private/log/syslog.php (renamed from lib/log/syslog.php)0
-rw-r--r--lib/private/mail.php (renamed from lib/mail.php)0
-rw-r--r--lib/private/memcache/apc.php (renamed from lib/memcache/apc.php)0
-rw-r--r--lib/private/memcache/apcu.php (renamed from lib/memcache/apcu.php)0
-rw-r--r--lib/private/memcache/cache.php (renamed from lib/memcache/cache.php)0
-rw-r--r--lib/private/memcache/factory.php (renamed from lib/memcache/factory.php)0
-rw-r--r--lib/private/memcache/memcached.php (renamed from lib/memcache/memcached.php)0
-rw-r--r--lib/private/memcache/xcache.php (renamed from lib/memcache/xcache.php)0
-rw-r--r--lib/private/migrate.php (renamed from lib/migrate.php)0
-rw-r--r--lib/private/migration/content.php (renamed from lib/migration/content.php)0
-rw-r--r--lib/private/migration/provider.php (renamed from lib/migration/provider.php)0
-rw-r--r--lib/private/mimetypes.list.php (renamed from lib/mimetypes.list.php)0
-rw-r--r--lib/private/minimizer.php (renamed from lib/minimizer.php)0
-rw-r--r--lib/private/minimizer/css.php (renamed from lib/minimizer/css.php)0
-rw-r--r--lib/private/minimizer/js.php (renamed from lib/minimizer/js.php)0
-rw-r--r--lib/private/navigationmanager.php64
-rw-r--r--lib/private/notsquareexception.php (renamed from lib/notsquareexception.php)0
-rw-r--r--lib/private/ocs.php (renamed from lib/ocs.php)0
-rw-r--r--lib/private/ocs/cloud.php (renamed from lib/ocs/cloud.php)0
-rw-r--r--lib/private/ocs/config.php (renamed from lib/ocs/config.php)0
-rw-r--r--lib/private/ocs/person.php (renamed from lib/ocs/person.php)0
-rw-r--r--lib/private/ocs/privatedata.php (renamed from lib/ocs/privatedata.php)0
-rw-r--r--lib/private/ocs/result.php (renamed from lib/ocs/result.php)0
-rw-r--r--lib/private/ocsclient.php (renamed from lib/ocsclient.php)7
-rw-r--r--lib/private/preferences.php (renamed from lib/preferences.php)0
-rwxr-xr-xlib/private/preview.php (renamed from lib/preview.php)5
-rw-r--r--lib/private/preview/image.php (renamed from lib/preview/image.php)0
-rw-r--r--lib/private/preview/movies.php (renamed from lib/preview/movies.php)0
-rw-r--r--lib/private/preview/mp3.php (renamed from lib/preview/mp3.php)0
-rw-r--r--lib/private/preview/office-cl.php (renamed from lib/preview/office-cl.php)0
-rw-r--r--lib/private/preview/office-fallback.php (renamed from lib/preview/office-fallback.php)0
-rw-r--r--lib/private/preview/office.php (renamed from lib/preview/office.php)0
-rw-r--r--lib/private/preview/pdf.php (renamed from lib/preview/pdf.php)0
-rw-r--r--lib/private/preview/provider.php (renamed from lib/preview/provider.php)0
-rw-r--r--lib/private/preview/svg.php (renamed from lib/preview/svg.php)0
-rw-r--r--lib/private/preview/txt.php (renamed from lib/preview/txt.php)0
-rw-r--r--lib/private/preview/unknown.php (renamed from lib/preview/unknown.php)0
-rwxr-xr-xlib/private/previewmanager.php38
-rwxr-xr-xlib/private/request.php (renamed from lib/request.php)0
-rw-r--r--lib/private/response.php (renamed from lib/response.php)0
-rw-r--r--lib/private/route.php (renamed from lib/route.php)8
-rw-r--r--lib/private/router.php (renamed from lib/router.php)0
-rw-r--r--lib/private/search.php (renamed from lib/search.php)0
-rw-r--r--lib/private/search/provider.php (renamed from lib/search/provider.php)0
-rw-r--r--lib/private/search/provider/file.php (renamed from lib/search/provider/file.php)0
-rw-r--r--lib/private/search/result.php (renamed from lib/search/result.php)0
-rw-r--r--lib/private/server.php293
-rw-r--r--lib/private/session/internal.php (renamed from lib/session/internal.php)0
-rw-r--r--lib/private/session/memory.php (renamed from lib/session/memory.php)0
-rw-r--r--lib/private/session/session.php (renamed from lib/session/session.php)2
-rw-r--r--lib/private/setup.php (renamed from lib/setup.php)0
-rw-r--r--lib/private/setup/abstractdatabase.php (renamed from lib/setup/abstractdatabase.php)0
-rw-r--r--lib/private/setup/mssql.php (renamed from lib/setup/mssql.php)0
-rw-r--r--lib/private/setup/mysql.php (renamed from lib/setup/mysql.php)0
-rw-r--r--lib/private/setup/oci.php (renamed from lib/setup/oci.php)0
-rw-r--r--lib/private/setup/postgresql.php (renamed from lib/setup/postgresql.php)0
-rw-r--r--lib/private/setup/sqlite.php (renamed from lib/setup/sqlite.php)0
-rw-r--r--lib/private/subadmin.php (renamed from lib/subadmin.php)0
-rw-r--r--lib/private/tagmanager.php68
-rw-r--r--lib/private/tags.php642
-rw-r--r--lib/private/template.php (renamed from lib/template.php)0
-rw-r--r--lib/private/template/base.php (renamed from lib/template/base.php)0
-rw-r--r--lib/private/template/cssresourcelocator.php (renamed from lib/template/cssresourcelocator.php)0
-rw-r--r--lib/private/template/functions.php (renamed from lib/template/functions.php)45
-rw-r--r--lib/private/template/jsresourcelocator.php (renamed from lib/template/jsresourcelocator.php)0
-rw-r--r--lib/private/template/resourcelocator.php (renamed from lib/template/resourcelocator.php)0
-rw-r--r--lib/private/template/templatefilelocator.php (renamed from lib/template/templatefilelocator.php)0
-rw-r--r--lib/private/templatelayout.php (renamed from lib/templatelayout.php)0
-rw-r--r--lib/private/updater.php (renamed from lib/updater.php)2
-rw-r--r--lib/private/user.php (renamed from lib/user.php)124
-rw-r--r--lib/private/user/backend.php (renamed from lib/user/backend.php)0
-rw-r--r--lib/private/user/database.php (renamed from lib/user/database.php)0
-rw-r--r--lib/private/user/dummy.php (renamed from lib/user/dummy.php)0
-rw-r--r--lib/private/user/example.php (renamed from lib/user/example.php)0
-rw-r--r--lib/private/user/http.php (renamed from lib/user/http.php)0
-rw-r--r--lib/private/user/interface.php (renamed from lib/user/interface.php)0
-rw-r--r--lib/private/user/manager.php (renamed from lib/user/manager.php)0
-rw-r--r--lib/private/user/session.php (renamed from lib/user/session.php)2
-rw-r--r--lib/private/user/user.php (renamed from lib/user/user.php)0
-rwxr-xr-xlib/private/util.php (renamed from lib/util.php)154
-rw-r--r--lib/private/vobject.php (renamed from lib/vobject.php)0
-rw-r--r--lib/private/vobject/compoundproperty.php (renamed from lib/vobject/compoundproperty.php)0
-rw-r--r--lib/private/vobject/stringproperty.php (renamed from lib/vobject/stringproperty.php)0
-rw-r--r--lib/public/app.php16
-rw-r--r--lib/public/appframework/app.php81
-rw-r--r--lib/public/appframework/http/http.php89
-rw-r--r--lib/public/appframework/http/jsonresponse.php74
-rw-r--r--lib/public/appframework/http/response.php169
-rw-r--r--lib/public/appframework/http/templateresponse.php126
-rw-r--r--lib/public/appframework/iapi.php151
-rw-r--r--lib/public/appframework/iappcontainer.php57
-rw-r--r--lib/public/appframework/middleware.php100
-rw-r--r--lib/public/authentication/iapachebackend.php49
-rw-r--r--lib/public/contacts.php55
-rw-r--r--lib/public/contacts/imanager.php150
-rw-r--r--lib/public/icache.php55
-rw-r--r--lib/public/iconfig.php65
-rw-r--r--lib/public/icontainer.php64
-rw-r--r--lib/public/idbconnection.php74
-rw-r--r--lib/public/ihelper.php23
-rw-r--r--lib/public/il10n.php67
-rw-r--r--lib/public/inavigationmanager.php27
-rw-r--r--lib/public/ipreview.php35
-rw-r--r--lib/public/irequest.php115
-rw-r--r--lib/public/iservercontainer.php142
-rw-r--r--lib/public/isession.php56
-rw-r--r--lib/public/itagmanager.php48
-rw-r--r--lib/public/itags.php164
-rw-r--r--lib/public/iurlgenerator.php47
-rw-r--r--lib/public/iusersession.php30
-rw-r--r--lib/public/preview.php34
-rw-r--r--lib/public/share.php90
-rw-r--r--lib/public/template.php4
-rw-r--r--lib/urlgenerator.php111
-rw-r--r--lib/vcategories.php821
313 files changed, 6557 insertions, 1338 deletions
diff --git a/lib/apphelper.php b/lib/apphelper.php
new file mode 100644
index 00000000000..bd02f3aabfa
--- /dev/null
+++ b/lib/apphelper.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * TODO: Description
+ */
+class AppHelper implements \OCP\IHelper {
+ /**
+ * Gets the content of an URL by using CURL or a fallback if it is not
+ * installed
+ * @param string $url the url that should be fetched
+ * @return string the content of the webpage
+ */
+ public function getUrlContent($url) {
+ return \OC_Util::getUrlContent($url);
+ }
+}
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 01841f831be..b5b58918372 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -73,9 +73,10 @@ class Autoloader {
}
} elseif (strpos($class, 'OC_') === 0) {
// first check for legacy classes if underscores are used
- $paths[] = 'legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
- $paths[] = strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
+ $paths[] = 'private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
+ $paths[] = 'private/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
} elseif (strpos($class, 'OC\\') === 0) {
+ $paths[] = 'private/' . strtolower(str_replace('\\', '/', substr($class, 3)) . '.php');
$paths[] = strtolower(str_replace('\\', '/', substr($class, 3)) . '.php');
} elseif (strpos($class, 'OCP\\') === 0) {
$paths[] = 'public/' . strtolower(str_replace('\\', '/', substr($class, 4)) . '.php');
@@ -117,7 +118,11 @@ class Autoloader {
// Does this PHP have an in-memory cache? We cache the paths there
if ($this->constructingMemoryCache && !$this->memoryCache) {
$this->constructingMemoryCache = false;
- $this->memoryCache = \OC\Memcache\Factory::createLowLatency('Autoloader');
+ try {
+ $this->memoryCache = \OC\Memcache\Factory::createLowLatency('Autoloader');
+ } catch(\Exception $ex) {
+ // no caching then - fine with me
+ }
}
if ($this->memoryCache) {
$pathsToRequire = $this->memoryCache->get($class);
diff --git a/lib/base.php b/lib/base.php
index 395d8486a5e..b0b2dca502f 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -84,6 +84,11 @@ class OC {
*/
public static $loader = null;
+ /**
+ * @var \OC\Server
+ */
+ public static $server = null;
+
public static function initPaths() {
// calculate the root directories
OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
@@ -159,7 +164,7 @@ class OC {
// set the right include path
set_include_path(
- OC::$SERVERROOT . '/lib' . PATH_SEPARATOR .
+ OC::$SERVERROOT . '/lib/private' . PATH_SEPARATOR .
OC::$SERVERROOT . '/config' . PATH_SEPARATOR .
OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR .
implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR .
@@ -451,6 +456,9 @@ class OC {
stream_wrapper_register('quota', 'OC\Files\Stream\Quota');
stream_wrapper_register('oc', 'OC\Files\Stream\OC');
+ // setup the basic server
+ self::$server = new \OC\Server();
+
self::initTemplateEngine();
if (!self::$CLI) {
self::initSession();
@@ -481,6 +489,11 @@ class OC {
if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('user_id')
&& $_SERVER['PHP_AUTH_USER'] != self::$session->get('user_id')) {
+ $sessionUser = self::$session->get('user_id');
+ $serverUser = $_SERVER['PHP_AUTH_USER'];
+ OC_Log::write('core',
+ "Session user-id ($sessionUser) doesn't match SERVER[PHP_AUTH_USER] ($serverUser).",
+ OC_Log::WARN);
OC_User::logout();
}
@@ -557,11 +570,13 @@ class OC {
if (OC_Config::getValue('installed', false)) { //don't try to do this before we are properly setup
// register cache cleanup jobs
try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception
- \OCP\BackgroundJob::registerJob('OC_Cache_FileGlobalGC');
+ \OCP\BackgroundJob::registerJob('OC\Cache\FileGlobalGC');
} catch (Exception $e) {
}
- OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
+ // NOTE: This will be replaced to use OCP
+ $userSession = \OC_User::getUserSession();
+ $userSession->listen('postLogin', '\OC\Cache\File', 'loginListener');
}
}
@@ -733,11 +748,17 @@ class OC {
protected static function handleLogin() {
OC_App::loadApps(array('prelogin'));
$error = array();
+
+ // auth possible via apache module?
+ if (OC::tryApacheAuth()) {
+ $error[] = 'apacheauthfailed';
+ }
// remember was checked after last login
- if (OC::tryRememberLogin()) {
+ elseif (OC::tryRememberLogin()) {
$error[] = 'invalidcookie';
- // Someone wants to log in :
- } elseif (OC::tryFormLogin()) {
+ }
+ // logon via web form
+ elseif (OC::tryFormLogin()) {
$error[] = 'invalidpassword';
}
@@ -755,11 +776,26 @@ class OC {
}
}
+ protected static function tryApacheAuth() {
+ $return = OC_User::handleApacheAuth();
+
+ // if return is true we are logged in -> redirect to the default page
+ if ($return === true) {
+ $_REQUEST['redirect_url'] = \OC_Request::requestUri();
+ OC_Util::redirectToDefaultPage();
+ exit;
+ }
+
+ // in case $return is null apache based auth is not enabled
+ return is_null($return) ? false : true;
+ }
+
protected static function tryRememberLogin() {
if (!isset($_COOKIE["oc_remember_login"])
|| !isset($_COOKIE["oc_token"])
|| !isset($_COOKIE["oc_username"])
|| !$_COOKIE["oc_remember_login"]
+ || !OC_Util::rememberLoginAllowed()
) {
return false;
}
diff --git a/lib/cache/fileglobalgc.php b/lib/cache/fileglobalgc.php
deleted file mode 100644
index a29c31f9063..00000000000
--- a/lib/cache/fileglobalgc.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-
-class OC_Cache_FileGlobalGC extends \OC\BackgroundJob\Job{
- public function run($argument){
- OC_Cache_FileGlobal::gc();
- }
-}
diff --git a/lib/l10n/ar.php b/lib/l10n/ar.php
index f626dcdfda6..6870c549940 100644
--- a/lib/l10n/ar.php
+++ b/lib/l10n/ar.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "اعداد كلمة مرور للمدير",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "اعدادات خادمك غير صحيحة بشكل تسمح لك بمزامنة ملفاتك وذلك بسبب أن واجهة WebDAV تبدو معطلة",
"Please double check the <a href='%s'>installation guides</a>." => "الرجاء التحقق من <a href='%s'>دليل التنصيب</a>.",
+"Could not find category \"%s\"" => "تعذر العثور على المجلد \"%s\"",
"seconds ago" => "منذ ثواني",
"_%n minute ago_::_%n minutes ago_" => array("","","","","",""),
"_%n hour ago_::_%n hours ago_" => array("","","","","",""),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "الشهر الماضي",
"_%n month ago_::_%n months ago_" => array("","","","","",""),
"last year" => "السنةالماضية",
-"years ago" => "سنة مضت",
-"Could not find category \"%s\"" => "تعذر العثور على المجلد \"%s\""
+"years ago" => "سنة مضت"
);
$PLURAL_FORMS = "nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;";
diff --git a/lib/l10n/bg_BG.php b/lib/l10n/bg_BG.php
index b6cc949eb8a..c9de3d64d89 100644
--- a/lib/l10n/bg_BG.php
+++ b/lib/l10n/bg_BG.php
@@ -36,6 +36,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Въведете парола за администратор.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Вашият web сървър все още не е удачно настроен да позволява синхронизация на файлове, защото WebDAV интерфейсът изглежда не работи.",
"Please double check the <a href='%s'>installation guides</a>." => "Моля направете повторна справка с <a href='%s'>ръководството за инсталиране</a>.",
+"Could not find category \"%s\"" => "Невъзможно откриване на категорията \"%s\"",
"seconds ago" => "преди секунди",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -45,7 +46,6 @@ $TRANSLATIONS = array(
"last month" => "последният месец",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "последната година",
-"years ago" => "последните години",
-"Could not find category \"%s\"" => "Невъзможно откриване на категорията \"%s\""
+"years ago" => "последните години"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php
index a8769224705..fef5dc3cb22 100644
--- a/lib/l10n/ca.php
+++ b/lib/l10n/ca.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Establiu una contrasenya per l'administrador.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "El servidor web no està configurat correctament per permetre la sincronització de fitxers perquè la interfície WebDAV sembla no funcionar correctament.",
"Please double check the <a href='%s'>installation guides</a>." => "Comproveu les <a href='%s'>guies d'instal·lació</a>.",
+"Could not find category \"%s\"" => "No s'ha trobat la categoria \"%s\"",
"seconds ago" => "segons enrere",
"_%n minute ago_::_%n minutes ago_" => array("fa %n minut","fa %n minuts"),
"_%n hour ago_::_%n hours ago_" => array("fa %n hora","fa %n hores"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("fa %n mes","fa %n mesos"),
"last year" => "l'any passat",
"years ago" => "anys enrere",
-"Caused by:" => "Provocat per:",
-"Could not find category \"%s\"" => "No s'ha trobat la categoria \"%s\""
+"Caused by:" => "Provocat per:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index ed31ae79529..145078c0bd2 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Zadejte heslo správce.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server není správně nastaven pro umožnění synchronizace, rozhraní WebDAV se zdá být rozbité.",
"Please double check the <a href='%s'>installation guides</a>." => "Zkonzultujte, prosím, <a href='%s'>průvodce instalací</a>.",
+"Could not find category \"%s\"" => "Nelze nalézt kategorii \"%s\"",
"seconds ago" => "před pár sekundami",
"_%n minute ago_::_%n minutes ago_" => array("před %n minutou","před %n minutami","před %n minutami"),
"_%n hour ago_::_%n hours ago_" => array("před %n hodinou","před %n hodinami","před %n hodinami"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("před %n měsícem","před %n měsíci","před %n měsíci"),
"last year" => "minulý rok",
"years ago" => "před lety",
-"Caused by:" => "Příčina:",
-"Could not find category \"%s\"" => "Nelze nalézt kategorii \"%s\""
+"Caused by:" => "Příčina:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;";
diff --git a/lib/l10n/cy_GB.php b/lib/l10n/cy_GB.php
index 6973b51878f..0a52f5df776 100644
--- a/lib/l10n/cy_GB.php
+++ b/lib/l10n/cy_GB.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Gosod cyfrinair y gweinyddwr.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Nid yw eich gweinydd wedi'i gyflunio eto i ganiatáu cydweddu ffeiliau oherwydd bod y rhyngwyneb WebDAV wedi torri.",
"Please double check the <a href='%s'>installation guides</a>." => "Gwiriwch y <a href='%s'>canllawiau gosod</a> eto.",
+"Could not find category \"%s\"" => "Methu canfod categori \"%s\"",
"seconds ago" => "eiliad yn ôl",
"_%n minute ago_::_%n minutes ago_" => array("","","",""),
"_%n hour ago_::_%n hours ago_" => array("","","",""),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "mis diwethaf",
"_%n month ago_::_%n months ago_" => array("","","",""),
"last year" => "y llynedd",
-"years ago" => "blwyddyn yn ôl",
-"Could not find category \"%s\"" => "Methu canfod categori \"%s\""
+"years ago" => "blwyddyn yn ôl"
);
$PLURAL_FORMS = "nplurals=4; plural=(n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3;";
diff --git a/lib/l10n/da.php b/lib/l10n/da.php
index 05a43f42ed9..e4734755ae0 100644
--- a/lib/l10n/da.php
+++ b/lib/l10n/da.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Angiv et admin kodeord.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din webserver er endnu ikke sat op til at tillade fil synkronisering fordi WebDAV grænsefladen virker ødelagt.",
"Please double check the <a href='%s'>installation guides</a>." => "Dobbelttjek venligst <a href='%s'>installations vejledningerne</a>.",
+"Could not find category \"%s\"" => "Kunne ikke finde kategorien \"%s\"",
"seconds ago" => "sekunder siden",
"_%n minute ago_::_%n minutes ago_" => array("%n minut siden","%n minutter siden"),
"_%n hour ago_::_%n hours ago_" => array("%n time siden","%n timer siden"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n måned siden","%n måneder siden"),
"last year" => "sidste år",
"years ago" => "år siden",
-"Caused by:" => "Forårsaget af:",
-"Could not find category \"%s\"" => "Kunne ikke finde kategorien \"%s\""
+"Caused by:" => "Forårsaget af:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/de.php b/lib/l10n/de.php
index 87e7a67b47b..136cdc6476f 100644
--- a/lib/l10n/de.php
+++ b/lib/l10n/de.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Setze Administrator Passwort",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Dein Web-Server ist noch nicht für Datei-Synchronisation bereit, weil die WebDAV-Schnittstelle vermutlich defekt ist.",
"Please double check the <a href='%s'>installation guides</a>." => "Bitte prüfe die <a href='%s'>Installationsanleitungen</a>.",
+"Could not find category \"%s\"" => "Die Kategorie \"%s\" konnte nicht gefunden werden.",
"seconds ago" => "Gerade eben",
"_%n minute ago_::_%n minutes ago_" => array("","Vor %n Minuten"),
"_%n hour ago_::_%n hours ago_" => array("","Vor %n Stunden"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","Vor %n Monaten"),
"last year" => "Letztes Jahr",
"years ago" => "Vor Jahren",
-"Caused by:" => "Verursacht durch:",
-"Could not find category \"%s\"" => "Die Kategorie \"%s\" konnte nicht gefunden werden."
+"Caused by:" => "Verursacht durch:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/de_CH.php b/lib/l10n/de_CH.php
index 33f3446a693..c4f06520b50 100644
--- a/lib/l10n/de_CH.php
+++ b/lib/l10n/de_CH.php
@@ -43,6 +43,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Setze Administrator Passwort",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ihr Web-Server ist noch nicht für eine Datei-Synchronisation konfiguriert, weil die WebDAV-Schnittstelle vermutlich defekt ist.",
"Please double check the <a href='%s'>installation guides</a>." => "Bitte prüfen Sie die <a href='%s'>Installationsanleitungen</a>.",
+"Could not find category \"%s\"" => "Die Kategorie «%s» konnte nicht gefunden werden.",
"seconds ago" => "Gerade eben",
"_%n minute ago_::_%n minutes ago_" => array("","Vor %n Minuten"),
"_%n hour ago_::_%n hours ago_" => array("","Vor %n Stunden"),
@@ -53,7 +54,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","Vor %n Monaten"),
"last year" => "Letztes Jahr",
"years ago" => "Vor Jahren",
-"Caused by:" => "Verursacht durch:",
-"Could not find category \"%s\"" => "Die Kategorie «%s» konnte nicht gefunden werden."
+"Caused by:" => "Verursacht durch:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php
index 09be0eea22d..76f0ee8457e 100644
--- a/lib/l10n/de_DE.php
+++ b/lib/l10n/de_DE.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Setze Administrator Passwort",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ihr Web-Server ist noch nicht für eine Datei-Synchronisation konfiguriert, weil die WebDAV-Schnittstelle vermutlich defekt ist.",
"Please double check the <a href='%s'>installation guides</a>." => "Bitte prüfen Sie die <a href='%s'>Installationsanleitungen</a>.",
+"Could not find category \"%s\"" => "Die Kategorie \"%s\" konnte nicht gefunden werden.",
"seconds ago" => "Gerade eben",
"_%n minute ago_::_%n minutes ago_" => array("Vor %n Minute","Vor %n Minuten"),
"_%n hour ago_::_%n hours ago_" => array("Vor %n Stunde","Vor %n Stunden"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("Vor %n Monat","Vor %n Monaten"),
"last year" => "Letztes Jahr",
"years ago" => "Vor Jahren",
-"Caused by:" => "Verursacht durch:",
-"Could not find category \"%s\"" => "Die Kategorie \"%s\" konnte nicht gefunden werden."
+"Caused by:" => "Verursacht durch:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index dcbf82d4a4b..7f74dafca74 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -39,6 +39,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Εισάγετε συνθηματικό διαχειριστή.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ο διακομιστής σας δεν έχει ρυθμιστεί κατάλληλα ώστε να επιτρέπει τον συγχρονισμό αρχείων γιατί η διεπαφή WebDAV πιθανόν να είναι κατεστραμμένη.",
"Please double check the <a href='%s'>installation guides</a>." => "Ελέγξτε ξανά τις <a href='%s'>οδηγίες εγκατάστασης</a>.",
+"Could not find category \"%s\"" => "Αδυναμία εύρεσης κατηγορίας \"%s\"",
"seconds ago" => "δευτερόλεπτα πριν",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -49,7 +50,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "τελευταίο χρόνο",
"years ago" => "χρόνια πριν",
-"Caused by:" => "Προκλήθηκε από:",
-"Could not find category \"%s\"" => "Αδυναμία εύρεσης κατηγορίας \"%s\""
+"Caused by:" => "Προκλήθηκε από:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/en_GB.php b/lib/l10n/en_GB.php
index d02f553eda8..26d44f39893 100644
--- a/lib/l10n/en_GB.php
+++ b/lib/l10n/en_GB.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Set an admin password.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Your web server is not yet properly setup to allow files synchronisation because the WebDAV interface seems to be broken.",
"Please double check the <a href='%s'>installation guides</a>." => "Please double check the <a href='%s'>installation guides</a>.",
+"Could not find category \"%s\"" => "Could not find category \"%s\"",
"seconds ago" => "seconds ago",
"_%n minute ago_::_%n minutes ago_" => array("%n minute ago","%n minutes ago"),
"_%n hour ago_::_%n hours ago_" => array("%n hour ago","%n hours ago"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n month ago","%n months ago"),
"last year" => "last year",
"years ago" => "years ago",
-"Caused by:" => "Caused by:",
-"Could not find category \"%s\"" => "Could not find category \"%s\""
+"Caused by:" => "Caused by:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/eo.php b/lib/l10n/eo.php
index 5311dd6eb15..53d1ec1854d 100644
--- a/lib/l10n/eo.php
+++ b/lib/l10n/eo.php
@@ -33,6 +33,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Starigi administran pasvorton.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Via TTT-servilo ankoraŭ ne ĝuste agordiĝis por permesi sinkronigi dosierojn ĉar la WebDAV-interfaco ŝajnas rompita.",
"Please double check the <a href='%s'>installation guides</a>." => "Bonvolu duoble kontroli la <a href='%s'>gvidilon por instalo</a>.",
+"Could not find category \"%s\"" => "Ne troviĝis kategorio “%s”",
"seconds ago" => "sekundoj antaŭe",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -42,7 +43,6 @@ $TRANSLATIONS = array(
"last month" => "lastamonate",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "lastajare",
-"years ago" => "jaroj antaŭe",
-"Could not find category \"%s\"" => "Ne troviĝis kategorio “%s”"
+"years ago" => "jaroj antaŭe"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/es.php b/lib/l10n/es.php
index 047d5d955bb..289ef360d1c 100644
--- a/lib/l10n/es.php
+++ b/lib/l10n/es.php
@@ -8,6 +8,9 @@ $TRANSLATIONS = array(
"Users" => "Usuarios",
"Admin" => "Administración",
"Failed to upgrade \"%s\"." => "Falló la actualización \"%s\".",
+"Custom profile pictures don't work with encryption yet" => "Las imágenes de perfil personalizadas no funcionan con el cifrado aún",
+"Unknown filetype" => "Tipo de archivo desconocido",
+"Invalid image" => "Imagen inválida",
"web services under your control" => "Servicios web bajo su control",
"cannot open \"%s\"" => "No se puede abrir \"%s\"",
"ZIP download is turned off." => "La descarga en ZIP está desactivada.",
@@ -53,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Configurar la contraseña del administrador.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Su servidor web aún no está configurado adecuadamente para permitir sincronización de archivos ya que la interfaz WebDAV parece no estar funcionando.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, vuelva a comprobar las <a href='%s'>guías de instalación</a>.",
+"Could not find category \"%s\"" => "No puede encontrar la categoria \"%s\"",
"seconds ago" => "hace segundos",
"_%n minute ago_::_%n minutes ago_" => array("Hace %n minuto","Hace %n minutos"),
"_%n hour ago_::_%n hours ago_" => array("Hace %n hora","Hace %n horas"),
@@ -63,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("Hace %n mes","Hace %n meses"),
"last year" => "año pasado",
"years ago" => "hace años",
-"Caused by:" => "Causado por:",
-"Could not find category \"%s\"" => "No puede encontrar la categoria \"%s\""
+"Caused by:" => "Causado por:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
index f637eb403ed..668c46b7b10 100644
--- a/lib/l10n/es_AR.php
+++ b/lib/l10n/es_AR.php
@@ -53,6 +53,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Configurar una contraseña de administrador.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Tu servidor web no está configurado todavía para permitir sincronización de archivos porque la interfaz WebDAV parece no funcionar.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, comprobá nuevamente la <a href='%s'>guía de instalación</a>.",
+"Could not find category \"%s\"" => "No fue posible encontrar la categoría \"%s\"",
"seconds ago" => "segundos atrás",
"_%n minute ago_::_%n minutes ago_" => array("Hace %n minuto","Hace %n minutos"),
"_%n hour ago_::_%n hours ago_" => array("Hace %n hora","Hace %n horas"),
@@ -63,7 +64,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("Hace %n mes","Hace %n meses"),
"last year" => "el año pasado",
"years ago" => "años atrás",
-"Caused by:" => "Provocado por:",
-"Could not find category \"%s\"" => "No fue posible encontrar la categoría \"%s\""
+"Caused by:" => "Provocado por:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/et_EE.php b/lib/l10n/et_EE.php
index 85dfaeb52d5..c1881141636 100644
--- a/lib/l10n/et_EE.php
+++ b/lib/l10n/et_EE.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Määra admini parool.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Veebiserveri ei ole veel korralikult seadistatud võimaldamaks failide sünkroniseerimist, kuna WebDAV liides näib olevat mittetoimiv.",
"Please double check the <a href='%s'>installation guides</a>." => "Palun tutvu veelkord <a href='%s'>paigalduse juhenditega</a>.",
+"Could not find category \"%s\"" => "Ei leia kategooriat \"%s\"",
"seconds ago" => "sekundit tagasi",
"_%n minute ago_::_%n minutes ago_" => array("","%n minutit tagasi"),
"_%n hour ago_::_%n hours ago_" => array("","%n tundi tagasi"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","%n kuud tagasi"),
"last year" => "viimasel aastal",
"years ago" => "aastat tagasi",
-"Caused by:" => "Põhjustaja:",
-"Could not find category \"%s\"" => "Ei leia kategooriat \"%s\""
+"Caused by:" => "Põhjustaja:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php
index 413819f4f94..9758fdd1f32 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -39,6 +39,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Ezarri administraziorako pasahitza.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Zure web zerbitzaria ez dago oraindik ongi konfiguratuta fitxategien sinkronizazioa egiteko, WebDAV interfazea ongi ez dagoela dirudi.",
"Please double check the <a href='%s'>installation guides</a>." => "Mesedez begiratu <a href='%s'>instalazio gidak</a>.",
+"Could not find category \"%s\"" => "Ezin da \"%s\" kategoria aurkitu",
"seconds ago" => "segundu",
"_%n minute ago_::_%n minutes ago_" => array("orain dela minutu %n","orain dela %n minutu"),
"_%n hour ago_::_%n hours ago_" => array("orain dela ordu %n","orain dela %n ordu"),
@@ -49,7 +50,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("orain dela hilabete %n","orain dela %n hilabete"),
"last year" => "joan den urtean",
"years ago" => "urte",
-"Caused by:" => "Honek eraginda:",
-"Could not find category \"%s\"" => "Ezin da \"%s\" kategoria aurkitu"
+"Caused by:" => "Honek eraginda:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/fa.php b/lib/l10n/fa.php
index e9cb695bade..788b3703966 100644
--- a/lib/l10n/fa.php
+++ b/lib/l10n/fa.php
@@ -36,6 +36,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "یک رمزعبور برای مدیر تنظیم نمایید.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "احتمالاً وب سرور شما طوری تنظیم نشده است که اجازه ی همگام سازی فایلها را بدهد زیرا به نظر میرسد رابط WebDAV از کار افتاده است.",
"Please double check the <a href='%s'>installation guides</a>." => "لطفاً دوباره <a href='%s'>راهنمای نصب</a>را بررسی کنید.",
+"Could not find category \"%s\"" => "دسته بندی %s یافت نشد",
"seconds ago" => "ثانیه‌ها پیش",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -45,7 +46,6 @@ $TRANSLATIONS = array(
"last month" => "ماه قبل",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "سال قبل",
-"years ago" => "سال‌های قبل",
-"Could not find category \"%s\"" => "دسته بندی %s یافت نشد"
+"years ago" => "سال‌های قبل"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php
index 1d2bdab749c..5e9a9a1a1f3 100644
--- a/lib/l10n/fi_FI.php
+++ b/lib/l10n/fi_FI.php
@@ -46,6 +46,7 @@ $TRANSLATIONS = array(
"Set an admin username." => "Aseta ylläpitäjän käyttäjätunnus.",
"Set an admin password." => "Aseta ylläpitäjän salasana.",
"Please double check the <a href='%s'>installation guides</a>." => "Lue tarkasti <a href='%s'>asennusohjeet</a>.",
+"Could not find category \"%s\"" => "Luokkaa \"%s\" ei löytynyt",
"seconds ago" => "sekuntia sitten",
"_%n minute ago_::_%n minutes ago_" => array("%n minuutti sitten","%n minuuttia sitten"),
"_%n hour ago_::_%n hours ago_" => array("%n tunti sitten","%n tuntia sitten"),
@@ -56,7 +57,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n kuukausi sitten","%n kuukautta sitten"),
"last year" => "viime vuonna",
"years ago" => "vuotta sitten",
-"Caused by:" => "Aiheuttaja:",
-"Could not find category \"%s\"" => "Luokkaa \"%s\" ei löytynyt"
+"Caused by:" => "Aiheuttaja:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php
index ab3d618849e..73cb724a58a 100644
--- a/lib/l10n/fr.php
+++ b/lib/l10n/fr.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Spécifiez un mot de passe administrateur.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Votre serveur web, n'est pas correctement configuré pour permettre la synchronisation des fichiers, car l'interface WebDav ne fonctionne pas comme il faut.",
"Please double check the <a href='%s'>installation guides</a>." => "Veuillez vous référer au <a href='%s'>guide d'installation</a>.",
+"Could not find category \"%s\"" => "Impossible de trouver la catégorie \"%s\"",
"seconds ago" => "il y a quelques secondes",
"_%n minute ago_::_%n minutes ago_" => array("","il y a %n minutes"),
"_%n hour ago_::_%n hours ago_" => array("","Il y a %n heures"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","Il y a %n mois"),
"last year" => "l'année dernière",
"years ago" => "il y a plusieurs années",
-"Caused by:" => "Causé par :",
-"Could not find category \"%s\"" => "Impossible de trouver la catégorie \"%s\""
+"Caused by:" => "Causé par :"
);
$PLURAL_FORMS = "nplurals=2; plural=(n > 1);";
diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php
index 406272d690f..ce3c7ecf488 100644
--- a/lib/l10n/gl.php
+++ b/lib/l10n/gl.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Estabeleza un contrasinal de administrador",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web non está aínda configurado adecuadamente para permitir a sincronización de ficheiros xa que semella que a interface WebDAV non está a funcionar.",
"Please double check the <a href='%s'>installation guides</a>." => "Volva comprobar as <a href='%s'>guías de instalación</a>",
+"Could not find category \"%s\"" => "Non foi posíbel atopar a categoría «%s»",
"seconds ago" => "segundos atrás",
"_%n minute ago_::_%n minutes ago_" => array("hai %n minuto","hai %n minutos"),
"_%n hour ago_::_%n hours ago_" => array("hai %n hora","hai %n horas"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("hai %n mes","hai %n meses"),
"last year" => "último ano",
"years ago" => "anos atrás",
-"Caused by:" => "Causado por:",
-"Could not find category \"%s\"" => "Non foi posíbel atopar a categoría «%s»"
+"Caused by:" => "Causado por:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/he.php b/lib/l10n/he.php
index ced6244ee91..5bbfffe9ae9 100644
--- a/lib/l10n/he.php
+++ b/lib/l10n/he.php
@@ -18,6 +18,7 @@ $TRANSLATIONS = array(
"Images" => "תמונות",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "שרת האינטרנט שלך אינו מוגדר לצורכי סנכרון קבצים עדיין כיוון שמנשק ה־WebDAV כנראה אינו תקין.",
"Please double check the <a href='%s'>installation guides</a>." => "נא לעיין שוב ב<a href='%s'>מדריכי ההתקנה</a>.",
+"Could not find category \"%s\"" => "לא ניתן למצוא את הקטגוריה „%s“",
"seconds ago" => "שניות",
"_%n minute ago_::_%n minutes ago_" => array("","לפני %n דקות"),
"_%n hour ago_::_%n hours ago_" => array("","לפני %n שעות"),
@@ -27,7 +28,6 @@ $TRANSLATIONS = array(
"last month" => "חודש שעבר",
"_%n month ago_::_%n months ago_" => array("","לפני %n חודשים"),
"last year" => "שנה שעברה",
-"years ago" => "שנים",
-"Could not find category \"%s\"" => "לא ניתן למצוא את הקטגוריה „%s“"
+"years ago" => "שנים"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php
index 7ec7621a655..e944291caee 100644
--- a/lib/l10n/hu_HU.php
+++ b/lib/l10n/hu_HU.php
@@ -1,11 +1,14 @@
<?php
$TRANSLATIONS = array(
+"No app name specified" => "Nincs az alkalmazás név megadva.",
"Help" => "Súgó",
"Personal" => "Személyes",
"Settings" => "Beállítások",
"Users" => "Felhasználók",
"Admin" => "Adminsztráció",
"Failed to upgrade \"%s\"." => "Sikertelen Frissítés \"%s\".",
+"Unknown filetype" => "Ismeretlen file tipús",
+"Invalid image" => "Hibás kép",
"web services under your control" => "webszolgáltatások saját kézben",
"cannot open \"%s\"" => "nem sikerült megnyitni \"%s\"",
"ZIP download is turned off." => "A ZIP-letöltés nincs engedélyezve.",
@@ -13,6 +16,10 @@ $TRANSLATIONS = array(
"Back to Files" => "Vissza a Fájlokhoz",
"Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagyok a zip tömörítéshez.",
"Download the files in smaller chunks, seperately or kindly ask your administrator." => "Tölts le a fileokat kisebb chunkokban, kölün vagy kérj segitséget a rendszergazdádtól.",
+"App does not provide an info.xml file" => "Az alkalmazás nem szolgáltatott info.xml file-t",
+"App can't be installed because it is not compatible with this version of ownCloud" => "Az alalmazás nem telepíthető, mert nem kompatibilis az ownClod ezzel a verziójával.",
+"App directory already exists" => "Az alkalmazás mappája már létezik",
+"Can't create app folder. Please fix permissions. %s" => "Nem lehetett létrehozni az alkalmzás mappáját. Kérlek ellenőrizd a jogosultásgokat. %s",
"Application is not enabled" => "Az alkalmazás nincs engedélyezve",
"Authentication error" => "Azonosítási hiba",
"Token expired. Please reload page." => "A token lejárt. Frissítse az oldalt.",
@@ -39,6 +46,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Állítson be egy jelszót az adminisztrációhoz.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Az Ön webkiszolgálója nincs megfelelően beállítva az állományok szinkronizálásához, mert a WebDAV-elérés úgy tűnik, nem működik.",
"Please double check the <a href='%s'>installation guides</a>." => "Kérjük tüzetesen tanulmányozza át a <a href='%s'>telepítési útmutatót</a>.",
+"Could not find category \"%s\"" => "Ez a kategória nem található: \"%s\"",
"seconds ago" => "pár másodperce",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -49,7 +57,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "tavaly",
"years ago" => "több éve",
-"Caused by:" => "Okozta:",
-"Could not find category \"%s\"" => "Ez a kategória nem található: \"%s\""
+"Caused by:" => "Okozta:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/id.php b/lib/l10n/id.php
index 080faddb321..0cbcddcc6dd 100644
--- a/lib/l10n/id.php
+++ b/lib/l10n/id.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Setel sandi admin.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Web server Anda belum dikonfigurasikan dengan baik untuk mengizinkan sinkronisasi berkas karena tampaknya antarmuka WebDAV rusak.",
"Please double check the <a href='%s'>installation guides</a>." => "Silakan periksa ulang <a href='%s'>panduan instalasi</a>.",
+"Could not find category \"%s\"" => "Tidak dapat menemukan kategori \"%s\"",
"seconds ago" => "beberapa detik yang lalu",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "bulan kemarin",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "tahun kemarin",
-"years ago" => "beberapa tahun lalu",
-"Could not find category \"%s\"" => "Tidak dapat menemukan kategori \"%s\""
+"years ago" => "beberapa tahun lalu"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/is.php b/lib/l10n/is.php
index 7512d278fb8..032289fd304 100644
--- a/lib/l10n/is.php
+++ b/lib/l10n/is.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Files" => "Skrár",
"Text" => "Texti",
"Images" => "Myndir",
+"Could not find category \"%s\"" => "Fann ekki flokkinn \"%s\"",
"seconds ago" => "sek.",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -25,7 +26,6 @@ $TRANSLATIONS = array(
"last month" => "síðasta mánuði",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "síðasta ári",
-"years ago" => "einhverjum árum",
-"Could not find category \"%s\"" => "Fann ekki flokkinn \"%s\""
+"years ago" => "einhverjum árum"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index b00789bc86f..91efcca7f49 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Imposta una password di amministrazione.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Il tuo server web non è configurato correttamente per consentire la sincronizzazione dei file poiché l'interfaccia WebDAV sembra essere danneggiata.",
"Please double check the <a href='%s'>installation guides</a>." => "Leggi attentamente le <a href='%s'>guide d'installazione</a>.",
+"Could not find category \"%s\"" => "Impossibile trovare la categoria \"%s\"",
"seconds ago" => "secondi fa",
"_%n minute ago_::_%n minutes ago_" => array("%n minuto fa","%n minuti fa"),
"_%n hour ago_::_%n hours ago_" => array("%n ora fa","%n ore fa"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n mese fa","%n mesi fa"),
"last year" => "anno scorso",
"years ago" => "anni fa",
-"Caused by:" => "Causato da:",
-"Could not find category \"%s\"" => "Impossibile trovare la categoria \"%s\""
+"Caused by:" => "Causato da:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index b9e6a0e6924..7023c829f8f 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "管理者のパスワードを設定。",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "WebDAVインタフェースが動作していないと考えられるため、あなたのWEBサーバはまだファイルの同期を許可するように適切な設定がされていません。",
"Please double check the <a href='%s'>installation guides</a>." => "<a href='%s'>インストールガイド</a>をよく確認してください。",
+"Could not find category \"%s\"" => "カテゴリ \"%s\" が見つかりませんでした",
"seconds ago" => "数秒前",
"_%n minute ago_::_%n minutes ago_" => array("%n 分前"),
"_%n hour ago_::_%n hours ago_" => array("%n 時間後"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n カ月後"),
"last year" => "一年前",
"years ago" => "年前",
-"Caused by:" => "原因は以下:",
-"Could not find category \"%s\"" => "カテゴリ \"%s\" が見つかりませんでした"
+"Caused by:" => "原因は以下:"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/ka_GE.php b/lib/l10n/ka_GE.php
index 8fbe34e6786..0cf6ab333e8 100644
--- a/lib/l10n/ka_GE.php
+++ b/lib/l10n/ka_GE.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "დააყენეთ ადმინისტრატორის პაროლი.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "თქვენი web სერვერი არ არის კონფიგურირებული ფაილ სინქრონიზაციისთვის, რადგან WebDAV ინტერფეისი შეიძლება იყოს გატეხილი.",
"Please double check the <a href='%s'>installation guides</a>." => "გთხოვთ გადაათვალიეროთ <a href='%s'>ინსტალაციის გზამკვლევი</a>.",
+"Could not find category \"%s\"" => "\"%s\" კატეგორიის მოძებნა ვერ მოხერხდა",
"seconds ago" => "წამის წინ",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "გასულ თვეში",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "ბოლო წელს",
-"years ago" => "წლის წინ",
-"Could not find category \"%s\"" => "\"%s\" კატეგორიის მოძებნა ვერ მოხერხდა"
+"years ago" => "წლის წინ"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/ko.php b/lib/l10n/ko.php
index eec5be65abd..3ef39fefa60 100644
--- a/lib/l10n/ko.php
+++ b/lib/l10n/ko.php
@@ -8,12 +8,16 @@ $TRANSLATIONS = array(
"Users" => "사용자",
"Admin" => "관리자",
"Failed to upgrade \"%s\"." => "\"%s\" 업그레이드에 실패했습니다.",
+"Custom profile pictures don't work with encryption yet" => "개개인의 프로필 사진은 아직은 암호화 되지 않습니다",
+"Unknown filetype" => "알수없는 파일형식",
+"Invalid image" => "잘못된 그림",
"web services under your control" => "내가 관리하는 웹 서비스",
"cannot open \"%s\"" => "\"%s\"을(를) 열 수 없습니다.",
"ZIP download is turned off." => "ZIP 다운로드가 비활성화되었습니다.",
"Files need to be downloaded one by one." => "파일을 개별적으로 다운로드해야 합니다.",
"Back to Files" => "파일로 돌아가기",
"Selected files too large to generate zip file." => "선택한 파일들은 ZIP 파일을 생성하기에 너무 큽니다.",
+"Download the files in smaller chunks, seperately or kindly ask your administrator." => "작은 조각들 안에 들어있는 파일들을 받고자 하신다면, 나누어서 받으시거나 혹은 시스템 관리자에게 정중하게 물어보십시오",
"No source specified when installing app" => "앱을 설치할 때 소스가 지정되지 않았습니다.",
"No href specified when installing app from http" => "http에서 앱을 설치할 대 href가 지정되지 않았습니다.",
"No path specified when installing app from local file" => "로컬 파일에서 앱을 설치할 때 경로가 지정되지 않았습니다.",
@@ -52,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "관리자 비밀번호 설정",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "WebDAV 인터페이스가 제대로 작동하지 않습니다. 웹 서버에서 파일 동기화를 사용할 수 있도록 설정이 제대로 되지 않은 것 같습니다.",
"Please double check the <a href='%s'>installation guides</a>." => "<a href='%s'>설치 가이드</a>를 다시 한 번 확인하십시오.",
+"Could not find category \"%s\"" => "분류 \"%s\"을(를) 찾을 수 없습니다.",
"seconds ago" => "초 전",
"_%n minute ago_::_%n minutes ago_" => array("%n분 전 "),
"_%n hour ago_::_%n hours ago_" => array("%n시간 전 "),
@@ -62,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n달 전 "),
"last year" => "작년",
"years ago" => "년 전",
-"Caused by:" => "원인: ",
-"Could not find category \"%s\"" => "분류 \"%s\"을(를) 찾을 수 없습니다."
+"Caused by:" => "원인: "
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/lt_LT.php b/lib/l10n/lt_LT.php
index db8d96c1018..72e84bc4b00 100644
--- a/lib/l10n/lt_LT.php
+++ b/lib/l10n/lt_LT.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Nustatyti administratoriaus slaptažodį.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Jūsų serveris nėra tvarkingai nustatytas leisti failų sinchronizaciją, nes WebDAV sąsaja panašu, kad yra sugadinta.",
"Please double check the <a href='%s'>installation guides</a>." => "Prašome pažiūrėkite dar kartą <a href='%s'>diegimo instrukcijas</a>.",
+"Could not find category \"%s\"" => "Nepavyko rasti kategorijos „%s“",
"seconds ago" => "prieš sekundę",
"_%n minute ago_::_%n minutes ago_" => array("prieš %n min.","Prieš % minutes","Prieš %n minučių"),
"_%n hour ago_::_%n hours ago_" => array("Prieš %n valandą","Prieš %n valandas","Prieš %n valandų"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("Prieš %n mėnesį","Prieš %n mėnesius","Prieš %n mėnesių"),
"last year" => "praeitais metais",
"years ago" => "prieš metus",
-"Caused by:" => "Iššaukė:",
-"Could not find category \"%s\"" => "Nepavyko rasti kategorijos „%s“"
+"Caused by:" => "Iššaukė:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php
index 4090a36edcc..cf96c4c4ab8 100644
--- a/lib/l10n/lv.php
+++ b/lib/l10n/lv.php
@@ -39,6 +39,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Iestatiet administratora paroli.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Jūsu serveris vēl nav pareizi iestatīts, lai ļautu sinhronizēt datnes, jo izskatās, ka WebDAV saskarne ir salauzta.",
"Please double check the <a href='%s'>installation guides</a>." => "Lūdzu, vēlreiz pārbaudiet <a href='%s'>instalēšanas palīdzību</a>.",
+"Could not find category \"%s\"" => "Nevarēja atrast kategoriju “%s”",
"seconds ago" => "sekundes atpakaļ",
"_%n minute ago_::_%n minutes ago_" => array("","","Pirms %n minūtēm"),
"_%n hour ago_::_%n hours ago_" => array("","","Pirms %n stundām"),
@@ -49,7 +50,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","","Pirms %n mēnešiem"),
"last year" => "gājušajā gadā",
"years ago" => "gadus atpakaļ",
-"Caused by:" => "Cēlonis:",
-"Could not find category \"%s\"" => "Nevarēja atrast kategoriju “%s”"
+"Caused by:" => "Cēlonis:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);";
diff --git a/lib/l10n/mk.php b/lib/l10n/mk.php
index 69d4a1cb694..285dfd682a4 100644
--- a/lib/l10n/mk.php
+++ b/lib/l10n/mk.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Files" => "Датотеки",
"Text" => "Текст",
"Images" => "Слики",
+"Could not find category \"%s\"" => "Не можам да најдам категорија „%s“",
"seconds ago" => "пред секунди",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -25,7 +26,6 @@ $TRANSLATIONS = array(
"last month" => "минатиот месец",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "минатата година",
-"years ago" => "пред години",
-"Could not find category \"%s\"" => "Не можам да најдам категорија „%s“"
+"years ago" => "пред години"
);
$PLURAL_FORMS = "nplurals=2; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : 1;";
diff --git a/lib/l10n/my_MM.php b/lib/l10n/my_MM.php
index 5f4b6ddc820..7fdf0d0285d 100644
--- a/lib/l10n/my_MM.php
+++ b/lib/l10n/my_MM.php
@@ -12,6 +12,7 @@ $TRANSLATIONS = array(
"Files" => "ဖိုင်များ",
"Text" => "စာသား",
"Images" => "ပုံရိပ်များ",
+"Could not find category \"%s\"" => "\"%s\"ခေါင်းစဉ်ကို ရှာမတွေ့ပါ",
"seconds ago" => "စက္ကန့်အနည်းငယ်က",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -21,7 +22,6 @@ $TRANSLATIONS = array(
"last month" => "ပြီးခဲ့သောလ",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "မနှစ်က",
-"years ago" => "နှစ် အရင်က",
-"Could not find category \"%s\"" => "\"%s\"ခေါင်းစဉ်ကို ရှာမတွေ့ပါ"
+"years ago" => "နှစ် အရင်က"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/nb_NO.php b/lib/l10n/nb_NO.php
index 8e7d095d369..eb5e8d766fd 100644
--- a/lib/l10n/nb_NO.php
+++ b/lib/l10n/nb_NO.php
@@ -18,6 +18,7 @@ $TRANSLATIONS = array(
"Images" => "Bilder",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din nettservev er ikke konfigurert korrekt for filsynkronisering. WebDAV ser ut til å ikke funkere.",
"Please double check the <a href='%s'>installation guides</a>." => "Vennligst dobbelsjekk <a href='%s'>installasjonsguiden</a>.",
+"Could not find category \"%s\"" => "Kunne ikke finne kategori \"%s\"",
"seconds ago" => "sekunder siden",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -27,7 +28,6 @@ $TRANSLATIONS = array(
"last month" => "forrige måned",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "forrige år",
-"years ago" => "år siden",
-"Could not find category \"%s\"" => "Kunne ikke finne kategori \"%s\""
+"years ago" => "år siden"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index 20374f1f0f8..d6dc9845d58 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Stel een beheerderswachtwoord in.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Uw webserver is nog niet goed ingesteld voor bestandssynchronisatie omdat de WebDAV interface verbroken lijkt.",
"Please double check the <a href='%s'>installation guides</a>." => "Controleer de <a href='%s'>installatiehandleiding</a> goed.",
+"Could not find category \"%s\"" => "Kon categorie \"%s\" niet vinden",
"seconds ago" => "seconden geleden",
"_%n minute ago_::_%n minutes ago_" => array("%n minuut geleden","%n minuten geleden"),
"_%n hour ago_::_%n hours ago_" => array("%n uur geleden","%n uur geleden"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n maand geleden","%n maanden geleden"),
"last year" => "vorig jaar",
"years ago" => "jaar geleden",
-"Caused by:" => "Gekomen door:",
-"Could not find category \"%s\"" => "Kon categorie \"%s\" niet vinden"
+"Caused by:" => "Gekomen door:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/pl.php b/lib/l10n/pl.php
index 4acd735d692..270559b4e50 100644
--- a/lib/l10n/pl.php
+++ b/lib/l10n/pl.php
@@ -8,6 +8,9 @@ $TRANSLATIONS = array(
"Users" => "Użytkownicy",
"Admin" => "Administrator",
"Failed to upgrade \"%s\"." => "Błąd przy aktualizacji \"%s\".",
+"Custom profile pictures don't work with encryption yet" => "Domyślny profil zdjęć nie działa z szyfrowaniem jeszcze",
+"Unknown filetype" => "Nieznany typ pliku",
+"Invalid image" => "Błędne zdjęcie",
"web services under your control" => "Kontrolowane serwisy",
"cannot open \"%s\"" => "Nie można otworzyć \"%s\"",
"ZIP download is turned off." => "Pobieranie ZIP jest wyłączone.",
@@ -53,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Ustaw hasło administratora.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Serwer internetowy nie jest jeszcze poprawnie skonfigurowany, aby umożliwić synchronizację plików, ponieważ interfejs WebDAV wydaje się być uszkodzony.",
"Please double check the <a href='%s'>installation guides</a>." => "Sprawdź ponownie <a href='%s'>przewodniki instalacji</a>.",
+"Could not find category \"%s\"" => "Nie można odnaleźć kategorii \"%s\"",
"seconds ago" => "sekund temu",
"_%n minute ago_::_%n minutes ago_" => array("%n minute temu","%n minut temu","%n minut temu"),
"_%n hour ago_::_%n hours ago_" => array("%n godzinę temu","%n godzin temu","%n godzin temu"),
@@ -63,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n miesiąc temu","%n miesięcy temu","%n miesięcy temu"),
"last year" => "w zeszłym roku",
"years ago" => "lat temu",
-"Caused by:" => "Spowodowane przez:",
-"Could not find category \"%s\"" => "Nie można odnaleźć kategorii \"%s\""
+"Caused by:" => "Spowodowane przez:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php
index 7a580799701..59bc7831619 100644
--- a/lib/l10n/pt_BR.php
+++ b/lib/l10n/pt_BR.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Defina uma senha de administrador.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Seu servidor web não está configurado corretamente para permitir sincronização de arquivos porque a interface WebDAV parece estar quebrada.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, confira os <a href='%s'>guias de instalação</a>.",
+"Could not find category \"%s\"" => "Impossível localizar categoria \"%s\"",
"seconds ago" => "segundos atrás",
"_%n minute ago_::_%n minutes ago_" => array("","ha %n minutos"),
"_%n hour ago_::_%n hours ago_" => array("","ha %n horas"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","ha %n meses"),
"last year" => "último ano",
"years ago" => "anos atrás",
-"Caused by:" => "Causados ​​por:",
-"Could not find category \"%s\"" => "Impossível localizar categoria \"%s\""
+"Caused by:" => "Causados ​​por:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n > 1);";
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
index 6e2bcba7b10..bc298a3f33f 100644
--- a/lib/l10n/pt_PT.php
+++ b/lib/l10n/pt_PT.php
@@ -41,6 +41,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Definiar uma password de administrador",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web não está configurado correctamente para autorizar sincronização de ficheiros, pois o interface WebDAV parece estar com problemas.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor verifique <a href='%s'>installation guides</a>.",
+"Could not find category \"%s\"" => "Não foi encontrado a categoria \"%s\"",
"seconds ago" => "Minutos atrás",
"_%n minute ago_::_%n minutes ago_" => array("","%n minutos atrás"),
"_%n hour ago_::_%n hours ago_" => array("","%n horas atrás"),
@@ -51,7 +52,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","%n meses atrás"),
"last year" => "ano passado",
"years ago" => "anos atrás",
-"Caused by:" => "Causado por:",
-"Could not find category \"%s\"" => "Não foi encontrado a categoria \"%s\""
+"Caused by:" => "Causado por:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/ro.php b/lib/l10n/ro.php
index 76dafcd03e0..94ff7a4326a 100644
--- a/lib/l10n/ro.php
+++ b/lib/l10n/ro.php
@@ -20,6 +20,7 @@ $TRANSLATIONS = array(
"Images" => "Imagini",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Serverul de web nu este încă setat corespunzător pentru a permite sincronizarea fișierelor deoarece interfața WebDAV pare a fi întreruptă.",
"Please double check the <a href='%s'>installation guides</a>." => "Vă rugăm să verificați <a href='%s'>ghiduri de instalare</a>.",
+"Could not find category \"%s\"" => "Cloud nu a gasit categoria \"%s\"",
"seconds ago" => "secunde în urmă",
"_%n minute ago_::_%n minutes ago_" => array("","","acum %n minute"),
"_%n hour ago_::_%n hours ago_" => array("","","acum %n ore"),
@@ -29,7 +30,6 @@ $TRANSLATIONS = array(
"last month" => "ultima lună",
"_%n month ago_::_%n months ago_" => array("","",""),
"last year" => "ultimul an",
-"years ago" => "ani în urmă",
-"Could not find category \"%s\"" => "Cloud nu a gasit categoria \"%s\""
+"years ago" => "ani în urmă"
);
$PLURAL_FORMS = "nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));";
diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php
index 501065f8b5f..c52248273a6 100644
--- a/lib/l10n/ru.php
+++ b/lib/l10n/ru.php
@@ -56,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "становит пароль для admin.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш веб сервер до сих пор не настроен правильно для возможности синхронизации файлов, похоже что проблема в неисправности интерфейса WebDAV.",
"Please double check the <a href='%s'>installation guides</a>." => "Пожалуйста, дважды просмотрите <a href='%s'>инструкции по установке</a>.",
+"Could not find category \"%s\"" => "Категория \"%s\" не найдена",
"seconds ago" => "несколько секунд назад",
"_%n minute ago_::_%n minutes ago_" => array("%n минута назад","%n минуты назад","%n минут назад"),
"_%n hour ago_::_%n hours ago_" => array("%n час назад","%n часа назад","%n часов назад"),
@@ -66,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n месяц назад","%n месяца назад","%n месяцев назад"),
"last year" => "в прошлом году",
"years ago" => "несколько лет назад",
-"Caused by:" => "Вызвано:",
-"Could not find category \"%s\"" => "Категория \"%s\" не найдена"
+"Caused by:" => "Вызвано:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
index 13487b039d6..d2476c5a2bb 100644
--- a/lib/l10n/sk_SK.php
+++ b/lib/l10n/sk_SK.php
@@ -53,6 +53,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Zadajte heslo administrátora.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server nie je správne nastavený na synchronizáciu, pretože rozhranie WebDAV je poškodené.",
"Please double check the <a href='%s'>installation guides</a>." => "Prosím skontrolujte <a href='%s'>inštalačnú príručku</a>.",
+"Could not find category \"%s\"" => "Nemožno nájsť danú kategóriu \"%s\"",
"seconds ago" => "pred sekundami",
"_%n minute ago_::_%n minutes ago_" => array("","","pred %n minútami"),
"_%n hour ago_::_%n hours ago_" => array("","","pred %n hodinami"),
@@ -63,7 +64,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","","pred %n mesiacmi"),
"last year" => "minulý rok",
"years ago" => "pred rokmi",
-"Caused by:" => "Príčina:",
-"Could not find category \"%s\"" => "Nemožno nájsť danú kategóriu \"%s\""
+"Caused by:" => "Príčina:"
);
$PLURAL_FORMS = "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;";
diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php
index 5722191aedf..286ec733205 100644
--- a/lib/l10n/sl.php
+++ b/lib/l10n/sl.php
@@ -36,6 +36,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Nastavi geslo skrbnika.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Spletni stražnik še ni ustrezno nastavljen in ne omogoča usklajevanja, saj je nastavitev WebDAV okvarjena.",
"Please double check the <a href='%s'>installation guides</a>." => "Preverite <a href='%s'>navodila namestitve</a>.",
+"Could not find category \"%s\"" => "Kategorije \"%s\" ni mogoče najti.",
"seconds ago" => "pred nekaj sekundami",
"_%n minute ago_::_%n minutes ago_" => array("","","",""),
"_%n hour ago_::_%n hours ago_" => array("","","",""),
@@ -45,7 +46,6 @@ $TRANSLATIONS = array(
"last month" => "zadnji mesec",
"_%n month ago_::_%n months ago_" => array("","","",""),
"last year" => "lansko leto",
-"years ago" => "let nazaj",
-"Could not find category \"%s\"" => "Kategorije \"%s\" ni mogoče najti."
+"years ago" => "let nazaj"
);
$PLURAL_FORMS = "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);";
diff --git a/lib/l10n/sq.php b/lib/l10n/sq.php
index edaa1df2b86..b36aa4ceefc 100644
--- a/lib/l10n/sq.php
+++ b/lib/l10n/sq.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Cakto kodin e administratorit.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Serveri web i juaji nuk është konfiguruar akoma për të lejuar sinkronizimin e skedarëve sepse ndërfaqja WebDAV mund të jetë e dëmtuar.",
"Please double check the <a href='%s'>installation guides</a>." => "Ju lutemi kontrolloni mirë <a href='%s'>shoqëruesin e instalimit</a>.",
+"Could not find category \"%s\"" => "Kategoria \"%s\" nuk u gjet",
"seconds ago" => "sekonda më parë",
"_%n minute ago_::_%n minutes ago_" => array("","%n minuta më parë"),
"_%n hour ago_::_%n hours ago_" => array("","%n orë më parë"),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "muajin e shkuar",
"_%n month ago_::_%n months ago_" => array("","%n muaj më parë"),
"last year" => "vitin e shkuar",
-"years ago" => "vite më parë",
-"Could not find category \"%s\"" => "Kategoria \"%s\" nuk u gjet"
+"years ago" => "vite më parë"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/sr.php b/lib/l10n/sr.php
index 9441d0578fc..47a84803683 100644
--- a/lib/l10n/sr.php
+++ b/lib/l10n/sr.php
@@ -18,6 +18,7 @@ $TRANSLATIONS = array(
"Images" => "Слике",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш веб сервер тренутно не подржава синхронизацију датотека јер се чини да је WebDAV сучеље неисправно.",
"Please double check the <a href='%s'>installation guides</a>." => "Погледајте <a href='%s'>водиче за инсталацију</a>.",
+"Could not find category \"%s\"" => "Не могу да пронађем категорију „%s“.",
"seconds ago" => "пре неколико секунди",
"_%n minute ago_::_%n minutes ago_" => array("","",""),
"_%n hour ago_::_%n hours ago_" => array("","",""),
@@ -27,7 +28,6 @@ $TRANSLATIONS = array(
"last month" => "прошлог месеца",
"_%n month ago_::_%n months ago_" => array("","",""),
"last year" => "прошле године",
-"years ago" => "година раније",
-"Could not find category \"%s\"" => "Не могу да пронађем категорију „%s“."
+"years ago" => "година раније"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/l10n/sv.php b/lib/l10n/sv.php
index e7c3420a85b..37f2e1d8c08 100644
--- a/lib/l10n/sv.php
+++ b/lib/l10n/sv.php
@@ -53,6 +53,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Ange ett administratörslösenord.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din webbserver är inte korrekt konfigurerad för att tillåta filsynkronisering eftersom WebDAV inte verkar fungera.",
"Please double check the <a href='%s'>installation guides</a>." => "Var god kontrollera <a href='%s'>installationsguiden</a>.",
+"Could not find category \"%s\"" => "Kunde inte hitta kategorin \"%s\"",
"seconds ago" => "sekunder sedan",
"_%n minute ago_::_%n minutes ago_" => array("%n minut sedan","%n minuter sedan"),
"_%n hour ago_::_%n hours ago_" => array("%n timme sedan","%n timmar sedan"),
@@ -63,7 +64,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n månad sedan","%n månader sedan"),
"last year" => "förra året",
"years ago" => "år sedan",
-"Caused by:" => "Orsakad av:",
-"Could not find category \"%s\"" => "Kunde inte hitta kategorin \"%s\""
+"Caused by:" => "Orsakad av:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/ta_LK.php b/lib/l10n/ta_LK.php
index e70e65845be..f761ccab0e2 100644
--- a/lib/l10n/ta_LK.php
+++ b/lib/l10n/ta_LK.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Files" => "கோப்புகள்",
"Text" => "உரை",
"Images" => "படங்கள்",
+"Could not find category \"%s\"" => "பிரிவு \"%s\" ஐ கண்டுப்பிடிக்க முடியவில்லை",
"seconds ago" => "செக்கன்களுக்கு முன்",
"_%n minute ago_::_%n minutes ago_" => array("",""),
"_%n hour ago_::_%n hours ago_" => array("",""),
@@ -25,7 +26,6 @@ $TRANSLATIONS = array(
"last month" => "கடந்த மாதம்",
"_%n month ago_::_%n months ago_" => array("",""),
"last year" => "கடந்த வருடம்",
-"years ago" => "வருடங்களுக்கு முன்",
-"Could not find category \"%s\"" => "பிரிவு \"%s\" ஐ கண்டுப்பிடிக்க முடியவில்லை"
+"years ago" => "வருடங்களுக்கு முன்"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/th_TH.php b/lib/l10n/th_TH.php
index 3344d0bb18e..173d0f2856b 100644
--- a/lib/l10n/th_TH.php
+++ b/lib/l10n/th_TH.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Files" => "ไฟล์",
"Text" => "ข้อความ",
"Images" => "รูปภาพ",
+"Could not find category \"%s\"" => "ไม่พบหมวดหมู่ \"%s\"",
"seconds ago" => "วินาที ก่อนหน้านี้",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -25,7 +26,6 @@ $TRANSLATIONS = array(
"last month" => "เดือนที่แล้ว",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "ปีที่แล้ว",
-"years ago" => "ปี ที่ผ่านมา",
-"Could not find category \"%s\"" => "ไม่พบหมวดหมู่ \"%s\""
+"years ago" => "ปี ที่ผ่านมา"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/tr.php b/lib/l10n/tr.php
index b63c37c7240..01f48517aec 100644
--- a/lib/l10n/tr.php
+++ b/lib/l10n/tr.php
@@ -53,6 +53,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Parola yonetici birlemek. ",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Web sunucunuz dosya transferi için düzgün bir şekilde yapılandırılmamış. WevDAV arabirimini sorunlu gözüküyor.",
"Please double check the <a href='%s'>installation guides</a>." => "Lütfen <a href='%s'>kurulum kılavuzlarını</a> iki kez kontrol edin.",
+"Could not find category \"%s\"" => "\"%s\" kategorisi bulunamadı",
"seconds ago" => "saniye önce",
"_%n minute ago_::_%n minutes ago_" => array("","%n dakika önce"),
"_%n hour ago_::_%n hours ago_" => array("","%n saat önce"),
@@ -63,7 +64,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("","%n ay önce"),
"last year" => "geçen yıl",
"years ago" => "yıl önce",
-"Caused by:" => "Neden olan:",
-"Could not find category \"%s\"" => "\"%s\" kategorisi bulunamadı"
+"Caused by:" => "Neden olan:"
);
$PLURAL_FORMS = "nplurals=2; plural=(n > 1);";
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index c1513c5bb79..906c93b567a 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -35,6 +35,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "Встановіть пароль адміністратора.",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш Web-сервер ще не налаштований належним чином для того, щоб дозволити синхронізацію файлів, через те що інтерфейс WebDAV, здається, зламаний.",
"Please double check the <a href='%s'>installation guides</a>." => "Будь ласка, перевірте <a href='%s'>інструкції по встановленню</a>.",
+"Could not find category \"%s\"" => "Не вдалося знайти категорію \"%s\"",
"seconds ago" => "секунди тому",
"_%n minute ago_::_%n minutes ago_" => array("","",""),
"_%n hour ago_::_%n hours ago_" => array("","",""),
@@ -44,7 +45,6 @@ $TRANSLATIONS = array(
"last month" => "минулого місяця",
"_%n month ago_::_%n months ago_" => array("","",""),
"last year" => "минулого року",
-"years ago" => "роки тому",
-"Could not find category \"%s\"" => "Не вдалося знайти категорію \"%s\""
+"years ago" => "роки тому"
);
$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/lib/l10n/vi.php b/lib/l10n/vi.php
index dc0045c35ca..5840283110e 100644
--- a/lib/l10n/vi.php
+++ b/lib/l10n/vi.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Files" => "Tập tin",
"Text" => "Văn bản",
"Images" => "Hình ảnh",
+"Could not find category \"%s\"" => "không thể tìm thấy mục \"%s\"",
"seconds ago" => "vài giây trước",
"_%n minute ago_::_%n minutes ago_" => array(""),
"_%n hour ago_::_%n hours ago_" => array(""),
@@ -25,7 +26,6 @@ $TRANSLATIONS = array(
"last month" => "tháng trước",
"_%n month ago_::_%n months ago_" => array(""),
"last year" => "năm trước",
-"years ago" => "năm trước",
-"Could not find category \"%s\"" => "không thể tìm thấy mục \"%s\""
+"years ago" => "năm trước"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/zh_CN.php b/lib/l10n/zh_CN.php
index 2c34356ea10..e3f2c949175 100644
--- a/lib/l10n/zh_CN.php
+++ b/lib/l10n/zh_CN.php
@@ -37,6 +37,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "请设置一个管理员密码。",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "您的Web服务器尚未正确设置以允许文件同步, 因为WebDAV的接口似乎已损坏.",
"Please double check the <a href='%s'>installation guides</a>." => "请认真检查<a href='%s'>安装指南</a>.",
+"Could not find category \"%s\"" => "无法找到分类 \"%s\"",
"seconds ago" => "秒前",
"_%n minute ago_::_%n minutes ago_" => array("%n 分钟前"),
"_%n hour ago_::_%n hours ago_" => array("%n 小时前"),
@@ -46,7 +47,6 @@ $TRANSLATIONS = array(
"last month" => "上月",
"_%n month ago_::_%n months ago_" => array("%n 月前"),
"last year" => "去年",
-"years ago" => "年前",
-"Could not find category \"%s\"" => "无法找到分类 \"%s\""
+"years ago" => "年前"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/l10n/zh_TW.php b/lib/l10n/zh_TW.php
index 210c766aa59..e56a451f8a9 100644
--- a/lib/l10n/zh_TW.php
+++ b/lib/l10n/zh_TW.php
@@ -8,6 +8,9 @@ $TRANSLATIONS = array(
"Users" => "使用者",
"Admin" => "管理",
"Failed to upgrade \"%s\"." => "升級失敗:%s",
+"Custom profile pictures don't work with encryption yet" => "自訂大頭貼暫時不能和加密功能同時使用",
+"Unknown filetype" => "未知的檔案類型",
+"Invalid image" => "無效的圖片",
"web services under your control" => "由您控制的網路服務",
"cannot open \"%s\"" => "無法開啓 %s",
"ZIP download is turned off." => "ZIP 下載已關閉。",
@@ -53,6 +56,7 @@ $TRANSLATIONS = array(
"Set an admin password." => "設定管理員密碼。",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "您的網頁伺服器尚未被正確設定來進行檔案同步,因為您的 WebDAV 界面似乎無法使用。",
"Please double check the <a href='%s'>installation guides</a>." => "請參考<a href='%s'>安裝指南</a>。",
+"Could not find category \"%s\"" => "找不到分類:\"%s\"",
"seconds ago" => "幾秒前",
"_%n minute ago_::_%n minutes ago_" => array("%n 分鐘前"),
"_%n hour ago_::_%n hours ago_" => array("%n 小時前"),
@@ -63,7 +67,6 @@ $TRANSLATIONS = array(
"_%n month ago_::_%n months ago_" => array("%n 個月前"),
"last year" => "去年",
"years ago" => "幾年前",
-"Caused by:" => "原因:",
-"Could not find category \"%s\"" => "找不到分類:\"%s\""
+"Caused by:" => "原因:"
);
$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
new file mode 100644
index 00000000000..72aabf60793
--- /dev/null
+++ b/lib/private/allconfig.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * Class to combine all the configuration options ownCloud offers
+ */
+class AllConfig implements \OCP\IConfig {
+ /**
+ * Sets a new system wide value
+ * @param string $key the key of the value, under which will be saved
+ * @param string $value the value that should be stored
+ * @todo need a use case for this
+ */
+// public function setSystemValue($key, $value) {
+// \OCP\Config::setSystemValue($key, $value);
+// }
+
+ /**
+ * Looks up a system wide defined value
+ * @param string $key the key of the value, under which it was saved
+ * @return string the saved value
+ */
+ public function getSystemValue($key) {
+ return \OCP\Config::getSystemValue($key, '');
+ }
+
+
+ /**
+ * Writes a new app wide value
+ * @param string $appName the appName that we want to store the value under
+ * @param string $key the key of the value, under which will be saved
+ * @param string $value the value that should be stored
+ */
+ public function setAppValue($appName, $key, $value) {
+ \OCP\Config::setAppValue($appName, $key, $value);
+ }
+
+ /**
+ * Looks up an app wide defined value
+ * @param string $appName the appName that we stored the value under
+ * @param string $key the key of the value, under which it was saved
+ * @return string the saved value
+ */
+ public function getAppValue($appName, $key) {
+ return \OCP\Config::getAppValue($appName, $key, '');
+ }
+
+
+ /**
+ * Set a user defined value
+ * @param string $userId the userId of the user that we want to store the value under
+ * @param string $appName the appName that we want to store the value under
+ * @param string $key the key under which the value is being stored
+ * @param string $value the value that you want to store
+ */
+ public function setUserValue($userId, $appName, $key, $value) {
+ \OCP\Config::setUserValue($userId, $appName, $key, $value);
+ }
+
+ /**
+ * Shortcut for getting a user defined value
+ * @param string $userId the userId of the user that we want to store the value under
+ * @param string $appName the appName that we stored the value under
+ * @param string $key the key under which the value is being stored
+ */
+ public function getUserValue($userId, $appName, $key){
+ return \OCP\Config::getUserValue($userId, $appName, $key);
+ }
+}
diff --git a/lib/api.php b/lib/private/api.php
index 31f3f968d9b..31f3f968d9b 100644
--- a/lib/api.php
+++ b/lib/private/api.php
diff --git a/lib/app.php b/lib/private/app.php
index d98af2dc296..0ab1ee57f63 100644
--- a/lib/app.php
+++ b/lib/private/app.php
@@ -27,8 +27,6 @@
* upgrading and removing apps.
*/
class OC_App{
- static private $activeapp = '';
- static private $navigation = array();
static private $settingsForms = array();
static private $adminForms = array();
static private $personalForms = array();
@@ -271,7 +269,7 @@ class OC_App{
/**
* @brief adds an entry to the navigation
- * @param string $data array containing the data
+ * @param array $data array containing the data
* @return bool
*
* This function adds a new entry to the navigation visible to users. $data
@@ -287,11 +285,7 @@ class OC_App{
* the navigation. Lower values come first.
*/
public static function addNavigationEntry( $data ) {
- $data['active']=false;
- if(!isset($data['icon'])) {
- $data['icon']='';
- }
- OC_App::$navigation[] = $data;
+ OC::$server->getNavigationManager()->add($data);
return true;
}
@@ -305,9 +299,7 @@ class OC_App{
* highlighting the current position of the user.
*/
public static function setActiveNavigationEntry( $id ) {
- // load all the apps, to make sure we have all the navigation entries
- self::loadApps();
- self::$activeapp = $id;
+ OC::$server->getNavigationManager()->setActiveEntry($id);
return true;
}
@@ -315,15 +307,14 @@ class OC_App{
* @brief Get the navigation entries for the $app
* @param string $app app
* @return array of the $data added with addNavigationEntry
+ *
+ * Warning: destroys the existing entries
*/
public static function getAppNavigationEntries($app) {
if(is_file(self::getAppPath($app).'/appinfo/app.php')) {
- $save = self::$navigation;
- self::$navigation = array();
+ OC::$server->getNavigationManager()->clear();
require $app.'/appinfo/app.php';
- $app_entries = self::$navigation;
- self::$navigation = $save;
- return $app_entries;
+ return OC::$server->getNavigationManager()->getAll();
}
return array();
}
@@ -336,7 +327,7 @@ class OC_App{
* setActiveNavigationEntry
*/
public static function getActiveNavigationEntry() {
- return self::$activeapp;
+ return OC::$server->getNavigationManager()->getActiveEntry();
}
/**
@@ -419,8 +410,9 @@ class OC_App{
// This is private as well. It simply works, so don't ask for more details
private static function proceedNavigation( $list ) {
+ $activeapp = OC::$server->getNavigationManager()->getActiveEntry();
foreach( $list as &$naventry ) {
- if( $naventry['id'] == self::$activeapp ) {
+ if( $naventry['id'] == $activeapp ) {
$naventry['active'] = true;
}
else{
@@ -572,7 +564,8 @@ class OC_App{
* - active: boolean, signals if the user is on this navigation entry
*/
public static function getNavigation() {
- $navigation = self::proceedNavigation( self::$navigation );
+ $entries = OC::$server->getNavigationManager()->getAll();
+ $navigation = self::proceedNavigation( $entries );
return $navigation;
}
diff --git a/lib/appconfig.php b/lib/private/appconfig.php
index e615d838173..e615d838173 100644
--- a/lib/appconfig.php
+++ b/lib/private/appconfig.php
diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php
new file mode 100644
index 00000000000..7ff55bb809d
--- /dev/null
+++ b/lib/private/appframework/app.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework;
+
+use OC\AppFramework\DependencyInjection\DIContainer;
+use OCP\AppFramework\IAppContainer;
+
+
+/**
+ * Entry point for every request in your app. You can consider this as your
+ * public static void main() method
+ *
+ * Handles all the dependency injection, controllers and output flow
+ */
+class App {
+
+
+ /**
+ * Shortcut for calling a controller method and printing the result
+ * @param string $controllerName the name of the controller under which it is
+ * stored in the DI container
+ * @param string $methodName the method that you want to call
+ * @param array $urlParams an array with variables extracted from the routes
+ * @param DIContainer $container an instance of a pimple container.
+ */
+ public static function main($controllerName, $methodName, array $urlParams,
+ IAppContainer $container) {
+ $container['urlParams'] = $urlParams;
+ $controller = $container[$controllerName];
+
+ // initialize the dispatcher and run all the middleware before the controller
+ $dispatcher = $container['Dispatcher'];
+
+ list($httpHeaders, $responseHeaders, $output) =
+ $dispatcher->dispatch($controller, $methodName);
+
+ if(!is_null($httpHeaders)) {
+ header($httpHeaders);
+ }
+
+ foreach($responseHeaders as $name => $value) {
+ header($name . ': ' . $value);
+ }
+
+ if(!is_null($output)) {
+ header('Content-Length: ' . strlen($output));
+ print($output);
+ }
+
+ }
+
+ /**
+ * Shortcut for calling a controller method and printing the result.
+ * Similar to App:main except that no headers will be sent.
+ * This should be used for example when registering sections via
+ * \OC\AppFramework\Core\API::registerAdmin()
+ *
+ * @param string $controllerName the name of the controller under which it is
+ * stored in the DI container
+ * @param string $methodName the method that you want to call
+ * @param array $urlParams an array with variables extracted from the routes
+ * @param DIContainer $container an instance of a pimple container.
+ */
+ public static function part($controllerName, $methodName, array $urlParams,
+ DIContainer $container){
+
+ $container['urlParams'] = $urlParams;
+ $controller = $container[$controllerName];
+
+ $dispatcher = $container['Dispatcher'];
+
+ list(, , $output) = $dispatcher->dispatch($controller, $methodName);
+ return $output;
+ }
+
+}
diff --git a/lib/private/appframework/controller/controller.php b/lib/private/appframework/controller/controller.php
new file mode 100644
index 00000000000..0ea0a38cc09
--- /dev/null
+++ b/lib/private/appframework/controller/controller.php
@@ -0,0 +1,142 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Controller;
+
+use OC\AppFramework\Http\Request;
+use OC\AppFramework\Core\API;
+use OCP\AppFramework\Http\TemplateResponse;
+
+
+/**
+ * Base class to inherit your controllers from
+ */
+abstract class Controller {
+
+ /**
+ * @var API instance of the api layer
+ */
+ protected $api;
+
+ protected $request;
+
+ /**
+ * @param API $api an api wrapper instance
+ * @param Request $request an instance of the request
+ */
+ public function __construct(API $api, Request $request){
+ $this->api = $api;
+ $this->request = $request;
+ }
+
+
+ /**
+ * Lets you access post and get parameters by the index
+ * @param string $key the key which you want to access in the URL Parameter
+ * placeholder, $_POST or $_GET array.
+ * The priority how they're returned is the following:
+ * 1. URL parameters
+ * 2. POST parameters
+ * 3. GET parameters
+ * @param mixed $default If the key is not found, this value will be returned
+ * @return mixed the content of the array
+ */
+ public function params($key, $default=null){
+ return $this->request->getParam($key, $default);
+ }
+
+
+ /**
+ * Returns all params that were received, be it from the request
+ * (as GET or POST) or throuh the URL by the route
+ * @return array the array with all parameters
+ */
+ public function getParams() {
+ return $this->request->getParams();
+ }
+
+
+ /**
+ * Returns the method of the request
+ * @return string the method of the request (POST, GET, etc)
+ */
+ public function method() {
+ return $this->request->getMethod();
+ }
+
+
+ /**
+ * Shortcut for accessing an uploaded file through the $_FILES array
+ * @param string $key the key that will be taken from the $_FILES array
+ * @return array the file in the $_FILES element
+ */
+ public function getUploadedFile($key) {
+ return $this->request->getUploadedFile($key);
+ }
+
+
+ /**
+ * Shortcut for getting env variables
+ * @param string $key the key that will be taken from the $_ENV array
+ * @return array the value in the $_ENV element
+ */
+ public function env($key) {
+ return $this->request->getEnv($key);
+ }
+
+
+ /**
+ * Shortcut for getting cookie variables
+ * @param string $key the key that will be taken from the $_COOKIE array
+ * @return array the value in the $_COOKIE element
+ */
+ public function cookie($key) {
+ return $this->request->getCookie($key);
+ }
+
+
+ /**
+ * Shortcut for rendering a template
+ * @param string $templateName the name of the template
+ * @param array $params the template parameters in key => value structure
+ * @param string $renderAs user renders a full page, blank only your template
+ * admin an entry in the admin settings
+ * @param array $headers set additional headers in name/value pairs
+ * @return \OCP\AppFramework\Http\TemplateResponse containing the page
+ */
+ public function render($templateName, array $params=array(),
+ $renderAs='user', array $headers=array()){
+ $response = new TemplateResponse($this->api, $templateName);
+ $response->setParams($params);
+ $response->renderAs($renderAs);
+
+ foreach($headers as $name => $value){
+ $response->addHeader($name, $value);
+ }
+
+ return $response;
+ }
+
+
+}
diff --git a/lib/private/appframework/core/api.php b/lib/private/appframework/core/api.php
new file mode 100644
index 00000000000..39522ee3dd5
--- /dev/null
+++ b/lib/private/appframework/core/api.php
@@ -0,0 +1,348 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Core;
+use OCP\AppFramework\IApi;
+
+
+/**
+ * This is used to wrap the owncloud static api calls into an object to make the
+ * code better abstractable for use in the dependency injection container
+ *
+ * Should you find yourself in need for more methods, simply inherit from this
+ * class and add your methods
+ */
+class API implements IApi{
+
+ private $appName;
+
+ /**
+ * constructor
+ * @param string $appName the name of your application
+ */
+ public function __construct($appName){
+ $this->appName = $appName;
+ }
+
+
+ /**
+ * Gets the userid of the current user
+ * @return string the user id of the current user
+ */
+ public function getUserId(){
+ return \OCP\User::getUser();
+ }
+
+
+ /**
+ * Adds a new javascript file
+ * @param string $scriptName the name of the javascript in js/ without the suffix
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ public function addScript($scriptName, $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+ \OCP\Util::addScript($appName, $scriptName);
+ }
+
+
+ /**
+ * Adds a new css file
+ * @param string $styleName the name of the css file in css/without the suffix
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ public function addStyle($styleName, $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+ \OCP\Util::addStyle($appName, $styleName);
+ }
+
+
+ /**
+ * shorthand for addScript for files in the 3rdparty directory
+ * @param string $name the name of the file without the suffix
+ */
+ public function add3rdPartyScript($name){
+ \OCP\Util::addScript($this->appName . '/3rdparty', $name);
+ }
+
+
+ /**
+ * shorthand for addStyle for files in the 3rdparty directory
+ * @param string $name the name of the file without the suffix
+ */
+ public function add3rdPartyStyle($name){
+ \OCP\Util::addStyle($this->appName . '/3rdparty', $name);
+ }
+
+
+ /**
+ * Returns the translation object
+ * @return \OC_L10N the translation object
+ */
+ public function getTrans(){
+ # TODO: use public api
+ return \OC_L10N::get($this->appName);
+ }
+
+
+ /**
+ * Returns the URL for a route
+ * @param string $routeName the name of the route
+ * @param array $arguments an array with arguments which will be filled into the url
+ * @return string the url
+ */
+ public function linkToRoute($routeName, $arguments=array()){
+ return \OCP\Util::linkToRoute($routeName, $arguments);
+ }
+
+
+ /**
+ * Returns an URL for an image or file
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ public function linkTo($file, $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+ return \OCP\Util::linkTo($appName, $file);
+ }
+
+
+ /**
+ * Returns the link to an image, like link to but only with prepending img/
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ public function imagePath($file, $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+ return \OCP\Util::imagePath($appName, $file);
+ }
+
+
+ /**
+ * Makes an URL absolute
+ * @param string $url the url
+ * @return string the absolute url
+ */
+ public function getAbsoluteURL($url){
+ # TODO: use public api
+ return \OC_Helper::makeURLAbsolute($url);
+ }
+
+
+ /**
+ * links to a file
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ * @deprecated replaced with linkToRoute()
+ * @return string the url
+ */
+ public function linkToAbsolute($file, $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+ return \OCP\Util::linkToAbsolute($appName, $file);
+ }
+
+
+ /**
+ * Checks if the CSRF check was correct
+ * @return bool true if CSRF check passed
+ */
+ public function passesCSRFCheck(){
+ # TODO: use public api
+ return \OC_Util::isCallRegistered();
+ }
+
+
+ /**
+ * Checks if an app is enabled
+ * @param string $appName the name of an app
+ * @return bool true if app is enabled
+ */
+ public function isAppEnabled($appName){
+ return \OCP\App::isEnabled($appName);
+ }
+
+
+ /**
+ * Writes a function into the error log
+ * @param string $msg the error message to be logged
+ * @param int $level the error level
+ */
+ public function log($msg, $level=null){
+ switch($level){
+ case 'debug':
+ $level = \OCP\Util::DEBUG;
+ break;
+ case 'info':
+ $level = \OCP\Util::INFO;
+ break;
+ case 'warn':
+ $level = \OCP\Util::WARN;
+ break;
+ case 'fatal':
+ $level = \OCP\Util::FATAL;
+ break;
+ default:
+ $level = \OCP\Util::ERROR;
+ break;
+ }
+ \OCP\Util::writeLog($this->appName, $msg, $level);
+ }
+
+
+ /**
+ * turns an owncloud path into a path on the filesystem
+ * @param string path the path to the file on the oc filesystem
+ * @return string the filepath in the filesystem
+ */
+ public function getLocalFilePath($path){
+ # TODO: use public api
+ return \OC_Filesystem::getLocalFile($path);
+ }
+
+
+ /**
+ * used to return and open a new eventsource
+ * @return \OC_EventSource a new open EventSource class
+ */
+ public function openEventSource(){
+ # TODO: use public api
+ return new \OC_EventSource();
+ }
+
+ /**
+ * @brief connects a function to a hook
+ * @param string $signalClass class name of emitter
+ * @param string $signalName name of signal
+ * @param string $slotClass class name of slot
+ * @param string $slotName name of slot, in another word, this is the
+ * name of the method that will be called when registered
+ * signal is emitted.
+ * @return bool, always true
+ */
+ public function connectHook($signalClass, $signalName, $slotClass, $slotName) {
+ return \OCP\Util::connectHook($signalClass, $signalName, $slotClass, $slotName);
+ }
+
+ /**
+ * @brief Emits a signal. To get data from the slot use references!
+ * @param string $signalClass class name of emitter
+ * @param string $signalName name of signal
+ * @param array $params defautl: array() array with additional data
+ * @return bool, true if slots exists or false if not
+ */
+ public function emitHook($signalClass, $signalName, $params = array()) {
+ return \OCP\Util::emitHook($signalClass, $signalName, $params);
+ }
+
+ /**
+ * @brief clear hooks
+ * @param string $signalClass
+ * @param string $signalName
+ */
+ public function clearHook($signalClass=false, $signalName=false) {
+ if ($signalClass) {
+ \OC_Hook::clear($signalClass, $signalName);
+ }
+ }
+
+ /**
+ * Gets the content of an URL by using CURL or a fallback if it is not
+ * installed
+ * @param string $url the url that should be fetched
+ * @return string the content of the webpage
+ */
+ public function getUrlContent($url) {
+ return \OC_Util::getUrlContent($url);
+ }
+
+ /**
+ * Register a backgroundjob task
+ * @param string $className full namespace and class name of the class
+ * @param string $methodName the name of the static method that should be
+ * called
+ */
+ public function addRegularTask($className, $methodName) {
+ \OCP\Backgroundjob::addRegularTask($className, $methodName);
+ }
+
+ /**
+ * Returns a template
+ * @param string $templateName the name of the template
+ * @param string $renderAs how it should be rendered
+ * @param string $appName the name of the app
+ * @return \OCP\Template a new template
+ */
+ public function getTemplate($templateName, $renderAs='user', $appName=null){
+ if($appName === null){
+ $appName = $this->appName;
+ }
+
+ if($renderAs === 'blank'){
+ return new \OCP\Template($appName, $templateName);
+ } else {
+ return new \OCP\Template($appName, $templateName, $renderAs);
+ }
+ }
+
+
+ /**
+ * Tells ownCloud to include a template in the admin overview
+ * @param string $mainPath the path to the main php file without the php
+ * suffix, relative to your apps directory! not the template directory
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ public function registerAdmin($mainPath, $appName=null) {
+ if($appName === null){
+ $appName = $this->appName;
+ }
+
+ \OCP\App::registerAdmin($appName, $mainPath);
+ }
+
+
+ /**
+ * get the filesystem info
+ *
+ * @param string $path
+ * @return array with the following keys:
+ * - size
+ * - mtime
+ * - mimetype
+ * - encrypted
+ * - versioned
+ */
+ public function getFileInfo($path) {
+ return \OC\Files\Filesystem::getFileInfo($path);
+ }
+
+}
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
new file mode 100644
index 00000000000..3755d45fa09
--- /dev/null
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\DependencyInjection;
+
+use OC\AppFramework\Http\Http;
+use OC\AppFramework\Http\Request;
+use OC\AppFramework\Http\Dispatcher;
+use OC\AppFramework\Core\API;
+use OC\AppFramework\Middleware\MiddlewareDispatcher;
+use OC\AppFramework\Middleware\Security\SecurityMiddleware;
+use OC\AppFramework\Utility\SimpleContainer;
+use OC\AppFramework\Utility\TimeFactory;
+use OCP\AppFramework\IApi;
+use OCP\AppFramework\IAppContainer;
+use OCP\AppFramework\IMiddleWare;
+use OCP\IServerContainer;
+
+
+class DIContainer extends SimpleContainer implements IAppContainer{
+
+ /**
+ * @var array
+ */
+ private $middleWares = array();
+
+ /**
+ * Put your class dependencies in here
+ * @param string $appName the name of the app
+ */
+ public function __construct($appName){
+
+ $this['AppName'] = $appName;
+
+ $this->registerParameter('ServerContainer', \OC::$server);
+
+ $this['API'] = $this->share(function($c){
+ return new API($c['AppName']);
+ });
+
+ /**
+ * Http
+ */
+ $this['Request'] = $this->share(function($c) {
+ /** @var $c SimpleContainer */
+ /** @var $server IServerContainer */
+ $server = $c->query('ServerContainer');
+ return $server->getRequest();
+ });
+
+ $this['Protocol'] = $this->share(function($c){
+ if(isset($_SERVER['SERVER_PROTOCOL'])) {
+ return new Http($_SERVER, $_SERVER['SERVER_PROTOCOL']);
+ } else {
+ return new Http($_SERVER);
+ }
+ });
+
+ $this['Dispatcher'] = $this->share(function($c) {
+ return new Dispatcher($c['Protocol'], $c['MiddlewareDispatcher']);
+ });
+
+
+ /**
+ * Middleware
+ */
+ $this['SecurityMiddleware'] = $this->share(function($c){
+ return new SecurityMiddleware($c['API'], $c['Request']);
+ });
+
+ $this['MiddlewareDispatcher'] = $this->share(function($c){
+ $dispatcher = new MiddlewareDispatcher();
+ $dispatcher->registerMiddleware($c['SecurityMiddleware']);
+
+ foreach($this->middleWares as $middleWare) {
+ $dispatcher->registerMiddleware($middleWare);
+ }
+
+ return $dispatcher;
+ });
+
+
+ /**
+ * Utilities
+ */
+ $this['TimeFactory'] = $this->share(function($c){
+ return new TimeFactory();
+ });
+
+
+ }
+
+
+ /**
+ * @return IApi
+ */
+ function getCoreApi()
+ {
+ return $this->query('API');
+ }
+
+ /**
+ * @return \OCP\IServerContainer
+ */
+ function getServer()
+ {
+ return $this->query('ServerContainer');
+ }
+
+ /**
+ * @param IMiddleWare $middleWare
+ * @return boolean
+ */
+ function registerMiddleWare(IMiddleWare $middleWare) {
+ array_push($this->middleWares, $middleWare);
+ }
+
+ /**
+ * used to return the appname of the set application
+ * @return string the name of your application
+ */
+ function getAppName() {
+ return $this->query('AppName');
+ }
+}
diff --git a/lib/private/appframework/http/dispatcher.php b/lib/private/appframework/http/dispatcher.php
new file mode 100644
index 00000000000..ea57a6860cc
--- /dev/null
+++ b/lib/private/appframework/http/dispatcher.php
@@ -0,0 +1,100 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt, Thomas Tanghus, Bart Visscher
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Http;
+
+use \OC\AppFramework\Controller\Controller;
+use \OC\AppFramework\Middleware\MiddlewareDispatcher;
+
+
+/**
+ * Class to dispatch the request to the middleware dispatcher
+ */
+class Dispatcher {
+
+ private $middlewareDispatcher;
+ private $protocol;
+
+
+ /**
+ * @param Http $protocol the http protocol with contains all status headers
+ * @param MiddlewareDispatcher $middlewareDispatcher the dispatcher which
+ * runs the middleware
+ */
+ public function __construct(Http $protocol,
+ MiddlewareDispatcher $middlewareDispatcher) {
+ $this->protocol = $protocol;
+ $this->middlewareDispatcher = $middlewareDispatcher;
+ }
+
+
+ /**
+ * Handles a request and calls the dispatcher on the controller
+ * @param Controller $controller the controller which will be called
+ * @param string $methodName the method name which will be called on
+ * the controller
+ * @return array $array[0] contains a string with the http main header,
+ * $array[1] contains headers in the form: $key => value, $array[2] contains
+ * the response output
+ */
+ public function dispatch(Controller $controller, $methodName) {
+ $out = array(null, array(), null);
+
+ try {
+
+ $this->middlewareDispatcher->beforeController($controller,
+ $methodName);
+ $response = $controller->$methodName();
+
+ // if an exception appears, the middleware checks if it can handle the
+ // exception and creates a response. If no response is created, it is
+ // assumed that theres no middleware who can handle it and the error is
+ // thrown again
+ } catch(\Exception $exception){
+ $response = $this->middlewareDispatcher->afterException(
+ $controller, $methodName, $exception);
+ if (is_null($response)) {
+ throw $exception;
+ }
+ }
+
+ $response = $this->middlewareDispatcher->afterController(
+ $controller, $methodName, $response);
+
+ // get the output which should be printed and run the after output
+ // middleware to modify the response
+ $output = $response->render();
+ $out[2] = $this->middlewareDispatcher->beforeOutput(
+ $controller, $methodName, $output);
+
+ // depending on the cache object the headers need to be changed
+ $out[0] = $this->protocol->getStatusHeader($response->getStatus(),
+ $response->getLastModified(), $response->getETag());
+ $out[1] = $response->getHeaders();
+
+ return $out;
+ }
+
+
+}
diff --git a/lib/private/appframework/http/downloadresponse.php b/lib/private/appframework/http/downloadresponse.php
new file mode 100644
index 00000000000..67b9542dba6
--- /dev/null
+++ b/lib/private/appframework/http/downloadresponse.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Http;
+
+
+/**
+ * Prompts the user to download the a file
+ */
+class DownloadResponse extends \OCP\AppFramework\Http\Response {
+
+ private $filename;
+ private $contentType;
+
+ /**
+ * Creates a response that prompts the user to download the file
+ * @param string $filename the name that the downloaded file should have
+ * @param string $contentType the mimetype that the downloaded file should have
+ */
+ public function __construct($filename, $contentType) {
+ $this->filename = $filename;
+ $this->contentType = $contentType;
+
+ $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
+ $this->addHeader('Content-Type', $contentType);
+ }
+
+
+}
diff --git a/lib/private/appframework/http/http.php b/lib/private/appframework/http/http.php
new file mode 100644
index 00000000000..e00dc9cdc4a
--- /dev/null
+++ b/lib/private/appframework/http/http.php
@@ -0,0 +1,148 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt, Thomas Tanghus, Bart Visscher
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Http;
+
+
+class Http extends \OCP\AppFramework\Http\Http{
+
+ private $server;
+ private $protocolVersion;
+ protected $headers;
+
+ /**
+ * @param $_SERVER $server
+ * @param string $protocolVersion the http version to use defaults to HTTP/1.1
+ */
+ public function __construct($server, $protocolVersion='HTTP/1.1') {
+ $this->server = $server;
+ $this->protocolVersion = $protocolVersion;
+
+ $this->headers = array(
+ self::STATUS_CONTINUE => 'Continue',
+ self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols',
+ self::STATUS_PROCESSING => 'Processing',
+ self::STATUS_OK => 'OK',
+ self::STATUS_CREATED => 'Created',
+ self::STATUS_ACCEPTED => 'Accepted',
+ self::STATUS_NON_AUTHORATIVE_INFORMATION => 'Non-Authorative Information',
+ self::STATUS_NO_CONTENT => 'No Content',
+ self::STATUS_RESET_CONTENT => 'Reset Content',
+ self::STATUS_PARTIAL_CONTENT => 'Partial Content',
+ self::STATUS_MULTI_STATUS => 'Multi-Status', // RFC 4918
+ self::STATUS_ALREADY_REPORTED => 'Already Reported', // RFC 5842
+ self::STATUS_IM_USED => 'IM Used', // RFC 3229
+ self::STATUS_MULTIPLE_CHOICES => 'Multiple Choices',
+ self::STATUS_MOVED_PERMANENTLY => 'Moved Permanently',
+ self::STATUS_FOUND => 'Found',
+ self::STATUS_SEE_OTHER => 'See Other',
+ self::STATUS_NOT_MODIFIED => 'Not Modified',
+ self::STATUS_USE_PROXY => 'Use Proxy',
+ self::STATUS_RESERVED => 'Reserved',
+ self::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect',
+ self::STATUS_BAD_REQUEST => 'Bad request',
+ self::STATUS_UNAUTHORIZED => 'Unauthorized',
+ self::STATUS_PAYMENT_REQUIRED => 'Payment Required',
+ self::STATUS_FORBIDDEN => 'Forbidden',
+ self::STATUS_NOT_FOUND => 'Not Found',
+ self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed',
+ self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable',
+ self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
+ self::STATUS_REQUEST_TIMEOUT => 'Request Timeout',
+ self::STATUS_CONFLICT => 'Conflict',
+ self::STATUS_GONE => 'Gone',
+ self::STATUS_LENGTH_REQUIRED => 'Length Required',
+ self::STATUS_PRECONDITION_FAILED => 'Precondition failed',
+ self::STATUS_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large',
+ self::STATUS_REQUEST_URI_TOO_LONG => 'Request-URI Too Long',
+ self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
+ self::STATUS_REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
+ self::STATUS_EXPECTATION_FAILED => 'Expectation Failed',
+ self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', // RFC 2324
+ self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', // RFC 4918
+ self::STATUS_LOCKED => 'Locked', // RFC 4918
+ self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', // RFC 4918
+ self::STATUS_UPGRADE_REQUIRED => 'Upgrade required',
+ self::STATUS_PRECONDITION_REQUIRED => 'Precondition required', // draft-nottingham-http-new-status
+ self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', // draft-nottingham-http-new-status
+ self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', // draft-nottingham-http-new-status
+ self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error',
+ self::STATUS_NOT_IMPLEMENTED => 'Not Implemented',
+ self::STATUS_BAD_GATEWAY => 'Bad Gateway',
+ self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable',
+ self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout',
+ self::STATUS_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported',
+ self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
+ self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', // RFC 4918
+ self::STATUS_LOOP_DETECTED => 'Loop Detected', // RFC 5842
+ self::STATUS_BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded', // non-standard
+ self::STATUS_NOT_EXTENDED => 'Not extended',
+ self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', // draft-nottingham-http-new-status
+ );
+ }
+
+
+ /**
+ * Gets the correct header
+ * @param Http::CONSTANT $status the constant from the Http class
+ * @param \DateTime $lastModified formatted last modified date
+ * @param string $Etag the etag
+ */
+ public function getStatusHeader($status, \DateTime $lastModified=null,
+ $ETag=null) {
+
+ if(!is_null($lastModified)) {
+ $lastModified = $lastModified->format(\DateTime::RFC2822);
+ }
+
+ // if etag or lastmodified have not changed, return a not modified
+ if ((isset($this->server['HTTP_IF_NONE_MATCH'])
+ && trim($this->server['HTTP_IF_NONE_MATCH']) === $ETag)
+
+ ||
+
+ (isset($this->server['HTTP_IF_MODIFIED_SINCE'])
+ && trim($this->server['HTTP_IF_MODIFIED_SINCE']) ===
+ $lastModified)) {
+
+ $status = self::STATUS_NOT_MODIFIED;
+ }
+
+ // we have one change currently for the http 1.0 header that differs
+ // from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND
+ // if this differs any more, we want to create childclasses for this
+ if($status === self::STATUS_TEMPORARY_REDIRECT
+ && $this->protocolVersion === 'HTTP/1.0') {
+
+ $status = self::STATUS_FOUND;
+ }
+
+ return $this->protocolVersion . ' ' . $status . ' ' .
+ $this->headers[$status];
+ }
+
+
+}
+
+
diff --git a/lib/private/appframework/http/redirectresponse.php b/lib/private/appframework/http/redirectresponse.php
new file mode 100644
index 00000000000..688447f1618
--- /dev/null
+++ b/lib/private/appframework/http/redirectresponse.php
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Http;
+
+use OCP\AppFramework\Http\Response;
+
+
+/**
+ * Redirects to a different URL
+ */
+class RedirectResponse extends Response {
+
+ private $redirectURL;
+
+ /**
+ * Creates a response that redirects to a url
+ * @param string $redirectURL the url to redirect to
+ */
+ public function __construct($redirectURL) {
+ $this->redirectURL = $redirectURL;
+ $this->setStatus(Http::STATUS_TEMPORARY_REDIRECT);
+ $this->addHeader('Location', $redirectURL);
+ }
+
+
+ /**
+ * @return string the url to redirect
+ */
+ public function getRedirectURL() {
+ return $this->redirectURL;
+ }
+
+
+}
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
new file mode 100644
index 00000000000..3e1f4ff87ed
--- /dev/null
+++ b/lib/private/appframework/http/request.php
@@ -0,0 +1,389 @@
+<?php
+/**
+ * ownCloud - Request
+ *
+ * @author Thomas Tanghus
+ * @copyright 2013 Thomas Tanghus (thomas@tanghus.net)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\AppFramework\Http;
+
+use OCP\IRequest;
+
+/**
+ * Class for accessing variables in the request.
+ * This class provides an immutable object with request variables.
+ */
+
+class Request implements \ArrayAccess, \Countable, IRequest {
+
+ protected $inputStream;
+ protected $content;
+ protected $items = array();
+ protected $allowedKeys = array(
+ 'get',
+ 'post',
+ 'files',
+ 'server',
+ 'env',
+ 'cookies',
+ 'urlParams',
+ 'parameters',
+ 'method',
+ 'requesttoken',
+ );
+
+ /**
+ * @param array $vars An associative array with the following optional values:
+ * @param array 'urlParams' the parameters which were matched from the URL
+ * @param array 'get' the $_GET array
+ * @param array|string 'post' the $_POST array or JSON string
+ * @param array 'files' the $_FILES array
+ * @param array 'server' the $_SERVER array
+ * @param array 'env' the $_ENV array
+ * @param array 'cookies' the $_COOKIE array
+ * @param string 'method' the request method (GET, POST etc)
+ * @param string|false 'requesttoken' the requesttoken or false when not available
+ * @see http://www.php.net/manual/en/reserved.variables.php
+ */
+ public function __construct(array $vars=array()) {
+
+ foreach($this->allowedKeys as $name) {
+ $this->items[$name] = isset($vars[$name])
+ ? $vars[$name]
+ : array();
+ }
+
+ if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
+ && in_array('fakeinput', stream_get_wrappers())) {
+ $this->inputStream = 'fakeinput://data';
+ } else {
+ $this->inputStream = 'php://input';
+ }
+
+ // Only 'application/x-www-form-urlencoded' requests are automatically
+ // transformed by PHP, 'application/json' must be decoded manually.
+ if ($this->method === 'POST'
+ && strpos($this->getHeader('Content-Type'), 'application/json') !== false
+ ) {
+ $this->items['params'] = $this->items['post'] = json_decode(file_get_contents($this->inputStream), true);
+ }
+
+ $this->items['parameters'] = array_merge(
+ $this->items['get'],
+ $this->items['post'],
+ $this->items['urlParams']
+ );
+
+ }
+
+ // Countable method.
+ public function count() {
+ return count(array_keys($this->items['parameters']));
+ }
+
+ /**
+ * ArrayAccess methods
+ *
+ * Gives access to the combined GET, POST and urlParams arrays
+ *
+ * Examples:
+ *
+ * $var = $request['myvar'];
+ *
+ * or
+ *
+ * if(!isset($request['myvar']) {
+ * // Do something
+ * }
+ *
+ * $request['myvar'] = 'something'; // This throws an exception.
+ *
+ * @param string $offset The key to lookup
+ * @return string|null
+ */
+ public function offsetExists($offset) {
+ return isset($this->items['parameters'][$offset]);
+ }
+
+ /**
+ * @see offsetExists
+ */
+ public function offsetGet($offset) {
+ return isset($this->items['parameters'][$offset])
+ ? $this->items['parameters'][$offset]
+ : null;
+ }
+
+ /**
+ * @see offsetExists
+ */
+ public function offsetSet($offset, $value) {
+ throw new \RuntimeException('You cannot change the contents of the request object');
+ }
+
+ /**
+ * @see offsetExists
+ */
+ public function offsetUnset($offset) {
+ throw new \RuntimeException('You cannot change the contents of the request object');
+ }
+
+ // Magic property accessors
+ public function __set($name, $value) {
+ throw new \RuntimeException('You cannot change the contents of the request object');
+ }
+
+ /**
+ * Access request variables by method and name.
+ * Examples:
+ *
+ * $request->post['myvar']; // Only look for POST variables
+ * $request->myvar; or $request->{'myvar'}; or $request->{$myvar}
+ * Looks in the combined GET, POST and urlParams array.
+ *
+ * If you access e.g. ->post but the current HTTP request method
+ * is GET a \LogicException will be thrown.
+ *
+ * @param string $name The key to look for.
+ * @throws \LogicException
+ * @return mixed|null
+ */
+ public function __get($name) {
+ switch($name) {
+ case 'put':
+ case 'patch':
+ case 'get':
+ case 'post':
+ if($this->method !== strtoupper($name)) {
+ throw new \LogicException(sprintf('%s cannot be accessed in a %s request.', $name, $this->method));
+ }
+ case 'files':
+ case 'server':
+ case 'env':
+ case 'cookies':
+ case 'parameters':
+ case 'params':
+ case 'urlParams':
+ if(in_array($name, array('put', 'patch'))) {
+ return $this->getContent($name);
+ } else {
+ return isset($this->items[$name])
+ ? $this->items[$name]
+ : null;
+ }
+ break;
+ case 'method':
+ return $this->items['method'];
+ break;
+ default;
+ return isset($this[$name])
+ ? $this[$name]
+ : null;
+ break;
+ }
+ }
+
+
+ public function __isset($name) {
+ return isset($this->items['parameters'][$name]);
+ }
+
+
+ public function __unset($id) {
+ throw new \RunTimeException('You cannot change the contents of the request object');
+ }
+
+ /**
+ * Returns the value for a specific http header.
+ *
+ * This method returns null if the header did not exist.
+ *
+ * @param string $name
+ * @return string
+ */
+ public function getHeader($name) {
+
+ $name = strtoupper(str_replace(array('-'),array('_'),$name));
+ if (isset($this->server['HTTP_' . $name])) {
+ return $this->server['HTTP_' . $name];
+ }
+
+ // There's a few headers that seem to end up in the top-level
+ // server array.
+ switch($name) {
+ case 'CONTENT_TYPE' :
+ case 'CONTENT_LENGTH' :
+ if (isset($this->server[$name])) {
+ return $this->server[$name];
+ }
+ break;
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Lets you access post and get parameters by the index
+ * In case of json requests the encoded json body is accessed
+ *
+ * @param string $key the key which you want to access in the URL Parameter
+ * placeholder, $_POST or $_GET array.
+ * The priority how they're returned is the following:
+ * 1. URL parameters
+ * 2. POST parameters
+ * 3. GET parameters
+ * @param mixed $default If the key is not found, this value will be returned
+ * @return mixed the content of the array
+ */
+ public function getParam($key, $default = null) {
+ return isset($this->parameters[$key])
+ ? $this->parameters[$key]
+ : $default;
+ }
+
+ /**
+ * Returns all params that were received, be it from the request
+ * (as GET or POST) or throuh the URL by the route
+ * @return array the array with all parameters
+ */
+ public function getParams() {
+ return $this->parameters;
+ }
+
+ /**
+ * Returns the method of the request
+ * @return string the method of the request (POST, GET, etc)
+ */
+ public function getMethod() {
+ return $this->method;
+ }
+
+ /**
+ * Shortcut for accessing an uploaded file through the $_FILES array
+ * @param string $key the key that will be taken from the $_FILES array
+ * @return array the file in the $_FILES element
+ */
+ public function getUploadedFile($key) {
+ return isset($this->files[$key]) ? $this->files[$key] : null;
+ }
+
+ /**
+ * Shortcut for getting env variables
+ * @param string $key the key that will be taken from the $_ENV array
+ * @return array the value in the $_ENV element
+ */
+ public function getEnv($key) {
+ return isset($this->env[$key]) ? $this->env[$key] : null;
+ }
+
+ /**
+ * Shortcut for getting cookie variables
+ * @param string $key the key that will be taken from the $_COOKIE array
+ * @return array the value in the $_COOKIE element
+ */
+ function getCookie($key) {
+ return isset($this->cookies[$key]) ? $this->cookies[$key] : null;
+ }
+
+ /**
+ * Returns the request body content.
+ *
+ * If the HTTP request method is PUT and the body
+ * not application/x-www-form-urlencoded or application/json a stream
+ * resource is returned, otherwise an array.
+ *
+ * @return array|string|resource The request body content or a resource to read the body stream.
+ *
+ * @throws \LogicException
+ */
+ protected function getContent() {
+ if ($this->content === false && $this->method === 'PUT') {
+ throw new \LogicException(
+ '"put" can only be accessed once if not '
+ . 'application/x-www-form-urlencoded or application/json.'
+ );
+ }
+
+ // If the content can't be parsed into an array then return a stream resource.
+ if ($this->method === 'PUT'
+ && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
+ && strpos($this->getHeader('Content-Type'), 'application/json') === false
+ ) {
+ $this->content = false;
+ return fopen($this->inputStream, 'rb');
+ }
+
+ if (is_null($this->content)) {
+ $this->content = file_get_contents($this->inputStream);
+
+ /*
+ * Normal jquery ajax requests are sent as application/x-www-form-urlencoded
+ * and in $_GET and $_POST PHP transformes the data into an array.
+ * The first condition mimics this.
+ * The second condition allows for sending raw application/json data while
+ * still getting the result as an array.
+ *
+ */
+ if (strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false) {
+ parse_str($this->content, $content);
+ if(is_array($content)) {
+ $this->content = $content;
+ }
+ } elseif (strpos($this->getHeader('Content-Type'), 'application/json') !== false) {
+ $content = json_decode($this->content, true);
+ if(is_array($content)) {
+ $this->content = $content;
+ }
+ }
+ }
+
+ return $this->content;
+ }
+
+ /**
+ * Checks if the CSRF check was correct
+ * @return bool true if CSRF check passed
+ * @see OC_Util::$callLifespan
+ * @see OC_Util::callRegister()
+ */
+ public function passesCSRFCheck() {
+ if($this->items['requesttoken'] === false) {
+ return false;
+ }
+
+ if (isset($this->items['get']['requesttoken'])) {
+ $token = $this->items['get']['requesttoken'];
+ } elseif (isset($this->items['post']['requesttoken'])) {
+ $token = $this->items['post']['requesttoken'];
+ } elseif (isset($this->items['server']['HTTP_REQUESTTOKEN'])) {
+ $token = $this->items['server']['HTTP_REQUESTTOKEN'];
+ } else {
+ //no token found.
+ return false;
+ }
+
+ // Check if the token is valid
+ if($token !== $this->items['requesttoken']) {
+ // Not valid
+ return false;
+ } else {
+ // Valid token
+ return true;
+ }
+ }}
diff --git a/lib/private/appframework/middleware/middlewaredispatcher.php b/lib/private/appframework/middleware/middlewaredispatcher.php
new file mode 100644
index 00000000000..c2377b8844b
--- /dev/null
+++ b/lib/private/appframework/middleware/middlewaredispatcher.php
@@ -0,0 +1,159 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Middleware;
+
+use OC\AppFramework\Controller\Controller;
+use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\MiddleWare;
+
+/**
+ * This class is used to store and run all the middleware in correct order
+ */
+class MiddlewareDispatcher {
+
+ /**
+ * @var array array containing all the middlewares
+ */
+ private $middlewares;
+
+ /**
+ * @var int counter which tells us what middlware was executed once an
+ * exception occurs
+ */
+ private $middlewareCounter;
+
+
+ /**
+ * Constructor
+ */
+ public function __construct(){
+ $this->middlewares = array();
+ $this->middlewareCounter = 0;
+ }
+
+
+ /**
+ * Adds a new middleware
+ * @param Middleware $middleware the middleware which will be added
+ */
+ public function registerMiddleware(Middleware $middleWare){
+ array_push($this->middlewares, $middleWare);
+ }
+
+
+ /**
+ * returns an array with all middleware elements
+ * @return array the middlewares
+ */
+ public function getMiddlewares(){
+ return $this->middlewares;
+ }
+
+
+ /**
+ * This is being run in normal order before the controller is being
+ * called which allows several modifications and checks
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ */
+ public function beforeController(Controller $controller, $methodName){
+ // we need to count so that we know which middlewares we have to ask in
+ // case theres an exception
+ for($i=0; $i<count($this->middlewares); $i++){
+ $this->middlewareCounter++;
+ $middleware = $this->middlewares[$i];
+ $middleware->beforeController($controller, $methodName);
+ }
+ }
+
+
+ /**
+ * This is being run when either the beforeController method or the
+ * controller method itself is throwing an exception. The middleware is asked
+ * in reverse order to handle the exception and to return a response.
+ * If the response is null, it is assumed that the exception could not be
+ * handled and the error will be thrown again
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param \Exception $exception the thrown exception
+ * @return Response a Response object if the middleware can handle the
+ * exception
+ * @throws \Exception the passed in exception if it cant handle it
+ */
+ public function afterException(Controller $controller, $methodName, \Exception $exception){
+ for($i=$this->middlewareCounter-1; $i>=0; $i--){
+ $middleware = $this->middlewares[$i];
+ try {
+ return $middleware->afterException($controller, $methodName, $exception);
+ } catch(\Exception $exception){
+ continue;
+ }
+ }
+ throw $exception;
+ }
+
+
+ /**
+ * This is being run after a successful controllermethod call and allows
+ * the manipulation of a Response object. The middleware is run in reverse order
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param Response $response the generated response from the controller
+ * @return Response a Response object
+ */
+ public function afterController(Controller $controller, $methodName, Response $response){
+ for($i=count($this->middlewares)-1; $i>=0; $i--){
+ $middleware = $this->middlewares[$i];
+ $response = $middleware->afterController($controller, $methodName, $response);
+ }
+ return $response;
+ }
+
+
+ /**
+ * This is being run after the response object has been rendered and
+ * allows the manipulation of the output. The middleware is run in reverse order
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param string $output the generated output from a response
+ * @return string the output that should be printed
+ */
+ public function beforeOutput(Controller $controller, $methodName, $output){
+ for($i=count($this->middlewares)-1; $i>=0; $i--){
+ $middleware = $this->middlewares[$i];
+ $output = $middleware->beforeOutput($controller, $methodName, $output);
+ }
+ return $output;
+ }
+
+}
diff --git a/lib/private/appframework/middleware/security/securityexception.php b/lib/private/appframework/middleware/security/securityexception.php
new file mode 100644
index 00000000000..b32a2769ff5
--- /dev/null
+++ b/lib/private/appframework/middleware/security/securityexception.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Middleware\Security;
+
+
+/**
+ * Thrown when the security middleware encounters a security problem
+ */
+class SecurityException extends \Exception {
+
+ /**
+ * @param string $msg the security error message
+ * @param bool $ajax true if it resulted because of an ajax request
+ */
+ public function __construct($msg, $code = 0) {
+ parent::__construct($msg, $code);
+ }
+
+}
diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php
new file mode 100644
index 00000000000..d6daf737bb4
--- /dev/null
+++ b/lib/private/appframework/middleware/security/securitymiddleware.php
@@ -0,0 +1,136 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Middleware\Security;
+
+use OC\AppFramework\Controller\Controller;
+use OC\AppFramework\Http\Http;
+use OC\AppFramework\Http\Request;
+use OC\AppFramework\Http\RedirectResponse;
+use OC\AppFramework\Utility\MethodAnnotationReader;
+use OC\AppFramework\Core\API;
+use OCP\AppFramework\Middleware;
+use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Http\JSONResponse;
+
+
+/**
+ * Used to do all the authentication and checking stuff for a controller method
+ * It reads out the annotations of a controller method and checks which if
+ * security things should be checked and also handles errors in case a security
+ * check fails
+ */
+class SecurityMiddleware extends Middleware {
+
+ private $api;
+
+ /**
+ * @var \OC\AppFramework\Http\Request
+ */
+ private $request;
+
+ /**
+ * @param API $api an instance of the api
+ */
+ public function __construct(API $api, Request $request){
+ $this->api = $api;
+ $this->request = $request;
+ }
+
+
+ /**
+ * This runs all the security checks before a method call. The
+ * security checks are determined by inspecting the controller method
+ * annotations
+ * @param string/Controller $controller the controllername or string
+ * @param string $methodName the name of the method
+ * @throws SecurityException when a security check fails
+ */
+ public function beforeController($controller, $methodName){
+
+ // get annotations from comments
+ $annotationReader = new MethodAnnotationReader($controller, $methodName);
+
+ // this will set the current navigation entry of the app, use this only
+ // for normal HTML requests and not for AJAX requests
+ $this->api->activateNavigationEntry();
+
+ // security checks
+ $isPublicPage = $annotationReader->hasAnnotation('PublicPage');
+ if(!$isPublicPage) {
+ if(!$this->api->isLoggedIn()) {
+ throw new SecurityException('Current user is not logged in', Http::STATUS_UNAUTHORIZED);
+ }
+
+ if(!$annotationReader->hasAnnotation('NoAdminRequired')) {
+ if(!$this->api->isAdminUser($this->api->getUserId())) {
+ throw new SecurityException('Logged in user must be an admin', Http::STATUS_FORBIDDEN);
+ }
+ }
+ }
+
+ if(!$annotationReader->hasAnnotation('NoCSRFRequired')) {
+ if(!$this->api->passesCSRFCheck()) {
+ throw new SecurityException('CSRF check failed', Http::STATUS_PRECONDITION_FAILED);
+ }
+ }
+
+ }
+
+
+ /**
+ * If an SecurityException is being caught, ajax requests return a JSON error
+ * response and non ajax requests redirect to the index
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param \Exception $exception the thrown exception
+ * @throws \Exception the passed in exception if it cant handle it
+ * @return Response a Response object or null in case that the exception could not be handled
+ */
+ public function afterException($controller, $methodName, \Exception $exception){
+ if($exception instanceof SecurityException){
+
+ if (stripos($this->request->getHeader('Accept'),'html')===false) {
+
+ $response = new JSONResponse(
+ array('message' => $exception->getMessage()),
+ $exception->getCode()
+ );
+ $this->api->log($exception->getMessage(), 'debug');
+ } else {
+
+ $url = $this->api->linkToAbsolute('index.php', ''); // TODO: replace with link to route
+ $response = new RedirectResponse($url);
+ $this->api->log($exception->getMessage(), 'debug');
+ }
+
+ return $response;
+
+ }
+
+ throw $exception;
+ }
+
+}
diff --git a/lib/private/appframework/routing/routeactionhandler.php b/lib/private/appframework/routing/routeactionhandler.php
new file mode 100644
index 00000000000..7fb56f14eab
--- /dev/null
+++ b/lib/private/appframework/routing/routeactionhandler.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * ownCloud - App Framework
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\AppFramework\routing;
+
+use \OC\AppFramework\App;
+use \OC\AppFramework\DependencyInjection\DIContainer;
+
+class RouteActionHandler {
+ private $controllerName;
+ private $actionName;
+ private $container;
+
+ public function __construct(DIContainer $container, $controllerName, $actionName) {
+ $this->controllerName = $controllerName;
+ $this->actionName = $actionName;
+ $this->container = $container;
+ }
+
+ public function __invoke($params) {
+ App::main($this->controllerName, $this->actionName, $params, $this->container);
+ }
+}
diff --git a/lib/private/appframework/routing/routeconfig.php b/lib/private/appframework/routing/routeconfig.php
new file mode 100644
index 00000000000..53ab11bf2f5
--- /dev/null
+++ b/lib/private/appframework/routing/routeconfig.php
@@ -0,0 +1,186 @@
+<?php
+/**
+ * ownCloud - App Framework
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\AppFramework\routing;
+
+use OC\AppFramework\DependencyInjection\DIContainer;
+
+/**
+ * Class RouteConfig
+ * @package OC\AppFramework\routing
+ */
+class RouteConfig {
+ private $container;
+ private $router;
+ private $routes;
+ private $appName;
+
+ /**
+ * @param \OC\AppFramework\DependencyInjection\DIContainer $container
+ * @param \OC_Router $router
+ * @param string $pathToYml
+ * @internal param $appName
+ */
+ public function __construct(DIContainer $container, \OC_Router $router, $routes) {
+ $this->routes = $routes;
+ $this->container = $container;
+ $this->router = $router;
+ $this->appName = $container['AppName'];
+ }
+
+ /**
+ * The routes and resource will be registered to the \OC_Router
+ */
+ public function register() {
+
+ // parse simple
+ $this->processSimpleRoutes($this->routes);
+
+ // parse resources
+ $this->processResources($this->routes);
+ }
+
+ /**
+ * Creates one route base on the give configuration
+ * @param $routes
+ * @throws \UnexpectedValueException
+ */
+ private function processSimpleRoutes($routes)
+ {
+ $simpleRoutes = isset($routes['routes']) ? $routes['routes'] : array();
+ foreach ($simpleRoutes as $simpleRoute) {
+ $name = $simpleRoute['name'];
+ $url = $simpleRoute['url'];
+ $verb = isset($simpleRoute['verb']) ? strtoupper($simpleRoute['verb']) : 'GET';
+
+ $split = explode('#', $name, 2);
+ if (count($split) != 2) {
+ throw new \UnexpectedValueException('Invalid route name');
+ }
+ $controller = $split[0];
+ $action = $split[1];
+
+ $controllerName = $this->buildControllerName($controller);
+ $actionName = $this->buildActionName($action);
+
+ // register the route
+ $handler = new RouteActionHandler($this->container, $controllerName, $actionName);
+ $this->router->create($this->appName.'.'.$controller.'.'.$action, $url)->method($verb)->action($handler);
+ }
+ }
+
+ /**
+ * For a given name and url restful routes are created:
+ * - index
+ * - show
+ * - new
+ * - create
+ * - update
+ * - destroy
+ *
+ * @param $routes
+ */
+ private function processResources($routes)
+ {
+ // declaration of all restful actions
+ $actions = array(
+ array('name' => 'index', 'verb' => 'GET', 'on-collection' => true),
+ array('name' => 'show', 'verb' => 'GET'),
+ array('name' => 'create', 'verb' => 'POST', 'on-collection' => true),
+ array('name' => 'update', 'verb' => 'PUT'),
+ array('name' => 'destroy', 'verb' => 'DELETE'),
+ );
+
+ $resources = isset($routes['resources']) ? $routes['resources'] : array();
+ foreach ($resources as $resource => $config) {
+
+ // the url parameter used as id to the resource
+ $resourceId = $this->buildResourceId($resource);
+ foreach($actions as $action) {
+ $url = $config['url'];
+ $method = $action['name'];
+ $verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
+ $collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
+ if (!$collectionAction) {
+ $url = $url . '/' . $resourceId;
+ }
+ if (isset($action['url-postfix'])) {
+ $url = $url . '/' . $action['url-postfix'];
+ }
+
+ $controller = $resource;
+
+ $controllerName = $this->buildControllerName($controller);
+ $actionName = $this->buildActionName($method);
+
+ $routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
+
+ $this->router->create($routeName, $url)->method($verb)->action(
+ new RouteActionHandler($this->container, $controllerName, $actionName)
+ );
+ }
+ }
+ }
+
+ /**
+ * Based on a given route name the controller name is generated
+ * @param $controller
+ * @return string
+ */
+ private function buildControllerName($controller)
+ {
+ return $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
+ }
+
+ /**
+ * Based on the action part of the route name the controller method name is generated
+ * @param $action
+ * @return string
+ */
+ private function buildActionName($action) {
+ return $this->underScoreToCamelCase($action);
+ }
+
+ /**
+ * Generates the id used in the url part o the route url
+ * @param $resource
+ * @return string
+ */
+ private function buildResourceId($resource) {
+ return '{'.$this->underScoreToCamelCase(rtrim($resource, 's')).'Id}';
+ }
+
+ /**
+ * Underscored strings are converted to camel case strings
+ * @param $str string
+ * @return string
+ */
+ private function underScoreToCamelCase($str) {
+ $pattern = "/_[a-z]?/";
+ return preg_replace_callback(
+ $pattern,
+ function ($matches) {
+ return strtoupper(ltrim($matches[0], "_"));
+ },
+ $str);
+ }
+}
diff --git a/lib/private/appframework/utility/methodannotationreader.php b/lib/private/appframework/utility/methodannotationreader.php
new file mode 100644
index 00000000000..42060a08529
--- /dev/null
+++ b/lib/private/appframework/utility/methodannotationreader.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Utility;
+
+
+/**
+ * Reads and parses annotations from doc comments
+ */
+class MethodAnnotationReader {
+
+ private $annotations;
+
+ /**
+ * @param object $object an object or classname
+ * @param string $method the method which we want to inspect for annotations
+ */
+ public function __construct($object, $method){
+ $this->annotations = array();
+
+ $reflection = new \ReflectionMethod($object, $method);
+ $docs = $reflection->getDocComment();
+
+ // extract everything prefixed by @ and first letter uppercase
+ preg_match_all('/@([A-Z]\w+)/', $docs, $matches);
+ $this->annotations = $matches[1];
+ }
+
+
+ /**
+ * Check if a method contains an annotation
+ * @param string $name the name of the annotation
+ * @return bool true if the annotation is found
+ */
+ public function hasAnnotation($name){
+ return in_array($name, $this->annotations);
+ }
+
+
+}
diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php
new file mode 100644
index 00000000000..7e4db63bde5
--- /dev/null
+++ b/lib/private/appframework/utility/simplecontainer.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace OC\AppFramework\Utility;
+
+// register 3rdparty autoloaders
+require_once __DIR__ . '/../../../../3rdparty/Pimple/Pimple.php';
+
+/**
+ * Class SimpleContainer
+ *
+ * SimpleContainer is a simple implementation of IContainer on basis of \Pimple
+ */
+class SimpleContainer extends \Pimple implements \OCP\IContainer {
+
+ /**
+ * @param string $name name of the service to query for
+ * @return object registered service for the given $name
+ */
+ public function query($name) {
+ return $this->offsetGet($name);
+ }
+
+ function registerParameter($name, $value)
+ {
+ $this[$name] = $value;
+ }
+
+ /**
+ * The given closure is call the first time the given service is queried.
+ * The closure has to return the instance for the given service.
+ * Created instance will be cached in case $shared is true.
+ *
+ * @param string $name name of the service to register another backend for
+ * @param callable $closure the closure to be called on service creation
+ */
+ function registerService($name, \Closure $closure, $shared = true)
+ {
+ if ($shared) {
+ $this[$name] = \Pimple::share($closure);
+ } else {
+ $this[$name] = $closure;
+ }
+ }
+}
diff --git a/lib/private/appframework/utility/timefactory.php b/lib/private/appframework/utility/timefactory.php
new file mode 100644
index 00000000000..2c3dd6cf5e3
--- /dev/null
+++ b/lib/private/appframework/utility/timefactory.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\AppFramework\Utility;
+
+
+/**
+ * Needed to mock calls to time()
+ */
+class TimeFactory {
+
+
+ /**
+ * @return int the result of a call to time()
+ */
+ public function getTime() {
+ return time();
+ }
+
+
+}
diff --git a/lib/archive.php b/lib/private/archive.php
index 85bfae57295..85bfae57295 100644
--- a/lib/archive.php
+++ b/lib/private/archive.php
diff --git a/lib/archive/tar.php b/lib/private/archive/tar.php
index a1c0535b1c3..a1c0535b1c3 100644
--- a/lib/archive/tar.php
+++ b/lib/private/archive/tar.php
diff --git a/lib/archive/zip.php b/lib/private/archive/zip.php
index 8a866716a79..8a866716a79 100644
--- a/lib/archive/zip.php
+++ b/lib/private/archive/zip.php
diff --git a/lib/arrayparser.php b/lib/private/arrayparser.php
index 3bb394a5163..3bb394a5163 100644
--- a/lib/arrayparser.php
+++ b/lib/private/arrayparser.php
diff --git a/lib/avatar.php b/lib/private/avatar.php
index f20980c364b..f20980c364b 100644
--- a/lib/avatar.php
+++ b/lib/private/avatar.php
diff --git a/lib/backgroundjob.php b/lib/private/backgroundjob.php
index 9619dcb732c..9619dcb732c 100644
--- a/lib/backgroundjob.php
+++ b/lib/private/backgroundjob.php
diff --git a/lib/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 49fbffbd684..49fbffbd684 100644
--- a/lib/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
diff --git a/lib/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index cc803dd9b5f..cc803dd9b5f 100644
--- a/lib/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
diff --git a/lib/backgroundjob/legacy/queuedjob.php b/lib/private/backgroundjob/legacy/queuedjob.php
index 2bc001103b8..2bc001103b8 100644
--- a/lib/backgroundjob/legacy/queuedjob.php
+++ b/lib/private/backgroundjob/legacy/queuedjob.php
diff --git a/lib/backgroundjob/legacy/regularjob.php b/lib/private/backgroundjob/legacy/regularjob.php
index d4cfa348cea..d4cfa348cea 100644
--- a/lib/backgroundjob/legacy/regularjob.php
+++ b/lib/private/backgroundjob/legacy/regularjob.php
diff --git a/lib/backgroundjob/queuedjob.php b/lib/private/backgroundjob/queuedjob.php
index 1714182820d..1714182820d 100644
--- a/lib/backgroundjob/queuedjob.php
+++ b/lib/private/backgroundjob/queuedjob.php
diff --git a/lib/backgroundjob/timedjob.php b/lib/private/backgroundjob/timedjob.php
index ae9f33505ab..ae9f33505ab 100644
--- a/lib/backgroundjob/timedjob.php
+++ b/lib/private/backgroundjob/timedjob.php
diff --git a/lib/cache.php b/lib/private/cache.php
index 48b9964ba9d..a311f10a00f 100644
--- a/lib/cache.php
+++ b/lib/private/cache.php
@@ -6,34 +6,36 @@
* See the COPYING-README file.
*/
-class OC_Cache {
+namespace OC;
+
+class Cache {
/**
- * @var OC_Cache $user_cache
+ * @var Cache $user_cache
*/
static protected $user_cache;
/**
- * @var OC_Cache $global_cache
+ * @var Cache $global_cache
*/
static protected $global_cache;
/**
* get the global cache
- * @return OC_Cache
+ * @return Cache
*/
static public function getGlobalCache() {
if (!self::$global_cache) {
- self::$global_cache = new OC_Cache_FileGlobal();
+ self::$global_cache = new Cache\FileGlobal();
}
return self::$global_cache;
}
/**
* get the user cache
- * @return OC_Cache
+ * @return Cache
*/
static public function getUserCache() {
if (!self::$user_cache) {
- self::$user_cache = new OC_Cache_File();
+ self::$user_cache = new Cache\File();
}
return self::$user_cache;
}
@@ -85,7 +87,7 @@ class OC_Cache {
/**
* clear the user cache of all entries starting with a prefix
- * @param string prefix (optional)
+ * @param string $prefix (optional)
* @return bool
*/
static public function clear($prefix='') {
@@ -93,6 +95,11 @@ class OC_Cache {
return $user_cache->clear($prefix);
}
+ /**
+ * creates cache key based on the files given
+ * @param $files
+ * @return string
+ */
static public function generateCacheKeyFromFiles($files) {
$key = '';
sort($files);
diff --git a/lib/cache/broker.php b/lib/private/cache/broker.php
index a161dbfa3bb..9b7e837e1bc 100644
--- a/lib/cache/broker.php
+++ b/lib/private/cache/broker.php
@@ -6,8 +6,18 @@
* See the COPYING-README file.
*/
-class OC_Cache_Broker {
+namespace OC\Cache;
+
+class Broker {
+
+ /**
+ * @var \OC\Cache
+ */
protected $fast_cache;
+
+ /**
+ * @var \OC\Cache
+ */
protected $slow_cache;
public function __construct($fast_cache, $slow_cache) {
diff --git a/lib/cache/file.php b/lib/private/cache/file.php
index eed2637c981..b0738d2a92b 100644
--- a/lib/cache/file.php
+++ b/lib/private/cache/file.php
@@ -6,24 +6,25 @@
* See the COPYING-README file.
*/
+namespace OC\Cache;
-class OC_Cache_File{
+class File {
protected $storage;
protected function getStorage() {
if (isset($this->storage)) {
return $this->storage;
}
- if(OC_User::isLoggedIn()) {
- \OC\Files\Filesystem::initMountPoints(OC_User::getUser());
+ if(\OC_User::isLoggedIn()) {
+ \OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
$subdir = 'cache';
- $view = new \OC\Files\View('/'.OC_User::getUser());
+ $view = new \OC\Files\View('/' . \OC_User::getUser());
if(!$view->file_exists($subdir)) {
$view->mkdir($subdir);
}
- $this->storage = new \OC\Files\View('/'.OC_User::getUser().'/'.$subdir);
+ $this->storage = new \OC\Files\View('/' . \OC_User::getUser().'/'.$subdir);
return $this->storage;
}else{
- OC_Log::write('core', 'Can\'t get cache storage, user not logged in', OC_Log::ERROR);
+ \OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
return false;
}
}
diff --git a/lib/cache/fileglobal.php b/lib/private/cache/fileglobal.php
index c0bd8e45f39..bd049bba4d0 100644
--- a/lib/cache/fileglobal.php
+++ b/lib/private/cache/fileglobal.php
@@ -6,10 +6,11 @@
* See the COPYING-README file.
*/
+namespace OC\Cache;
-class OC_Cache_FileGlobal{
+class FileGlobal {
static protected function getCacheDir() {
- $cache_dir = get_temp_dir().'/owncloud-'.OC_Util::getInstanceId().'/';
+ $cache_dir = get_temp_dir().'/owncloud-' . \OC_Util::getInstanceId().'/';
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
@@ -80,13 +81,13 @@ class OC_Cache_FileGlobal{
}
static public function gc() {
- $last_run = OC_AppConfig::getValue('core', 'global_cache_gc_lastrun', 0);
+ $last_run = \OC_AppConfig::getValue('core', 'global_cache_gc_lastrun', 0);
$now = time();
if (($now - $last_run) < 300) {
// only do cleanup every 5 minutes
return;
}
- OC_AppConfig::setValue('core', 'global_cache_gc_lastrun', $now);
+ \OC_AppConfig::setValue('core', 'global_cache_gc_lastrun', $now);
$cache_dir = self::getCacheDir();
if($cache_dir and is_dir($cache_dir)) {
$dh=opendir($cache_dir);
diff --git a/lib/private/cache/fileglobalgc.php b/lib/private/cache/fileglobalgc.php
new file mode 100644
index 00000000000..399dd5e6f94
--- /dev/null
+++ b/lib/private/cache/fileglobalgc.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace OC\Cache;
+
+class FileGlobalGC extends \OC\BackgroundJob\Job{
+ public function run($argument){
+ FileGlobal::gc();
+ }
+}
diff --git a/lib/private/cache/usercache.php b/lib/private/cache/usercache.php
new file mode 100644
index 00000000000..baa8820700b
--- /dev/null
+++ b/lib/private/cache/usercache.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+namespace OC\Cache;
+
+/**
+ * This interface defines method for accessing the file based user cache.
+ */
+class UserCache implements \OCP\ICache {
+
+ /**
+ * @var \OC\Cache\File $userCache
+ */
+ protected $userCache;
+
+ public function __construct() {
+ $this->userCache = new File();
+ }
+
+ /**
+ * Get a value from the user cache
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function get($key) {
+ return $this->userCache->get($key);
+ }
+
+ /**
+ * Set a value in the user cache
+ *
+ * @param string $key
+ * @param mixed $value
+ * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
+ * @return bool
+ */
+ public function set($key, $value, $ttl = 0) {
+ if (empty($key)) {
+ return false;
+ }
+ return $this->userCache->set($key, $value, $ttl);
+ }
+
+ /**
+ * Check if a value is set in the user cache
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function hasKey($key) {
+ return $this->userCache->hasKey($key);
+ }
+
+ /**
+ * Remove an item from the user cache
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function remove($key) {
+ return $this->userCache->remove($key);
+ }
+
+ /**
+ * clear the user cache of all entries starting with a prefix
+ * @param string $prefix (optional)
+ * @return bool
+ */
+ public function clear($prefix = '') {
+ return $this->userCache->clear($prefix);
+ }
+}
diff --git a/lib/config.php b/lib/private/config.php
index e773e6e2eb0..72423137fa3 100644
--- a/lib/config.php
+++ b/lib/private/config.php
@@ -160,7 +160,6 @@ class Config {
*/
private function writeData() {
// Create a php file ...
- $defaults = new \OC_Defaults;
$content = "<?php\n";
if ($this->debugMode) {
$content .= "define('DEBUG',true);\n";
@@ -172,6 +171,7 @@ class Config {
// Write the file
$result = @file_put_contents($this->configFilename, $content);
if (!$result) {
+ $defaults = new \OC_Defaults;
$url = $defaults->getDocBaseUrl() . '/server/5.0/admin_manual/installation/installation_source.html#set-the-directory-permissions';
throw new HintException(
"Can't write into config directory!",
diff --git a/lib/connector/sabre/ServiceUnavailable.php b/lib/private/connector/sabre/ServiceUnavailable.php
index c1cc815c989..c1cc815c989 100644
--- a/lib/connector/sabre/ServiceUnavailable.php
+++ b/lib/private/connector/sabre/ServiceUnavailable.php
diff --git a/lib/connector/sabre/aborteduploaddetectionplugin.php b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
index 15dca3a6809..10cca647e8d 100644
--- a/lib/connector/sabre/aborteduploaddetectionplugin.php
+++ b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
@@ -53,6 +53,12 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
*/
public function verifyContentLength($filePath, Sabre_DAV_INode $node = null) {
+ // we should only react on PUT which is used for upload
+ // e.g. with LOCK this will not work, but LOCK uses createFile() as well
+ if ($this->server->httpRequest->getMethod() !== 'PUT' ) {
+ return;
+ }
+
// ownCloud chunked upload will be handled in its own plugin
$chunkHeader = $this->server->httpRequest->getHeader('OC-Chunked');
if ($chunkHeader) {
diff --git a/lib/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php
index bf3a49593cb..d2fd74c44f9 100644
--- a/lib/connector/sabre/auth.php
+++ b/lib/private/connector/sabre/auth.php
@@ -72,6 +72,11 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
* @return bool
*/
public function authenticate(Sabre_DAV_Server $server, $realm) {
+
+ if (OC_User::handleApacheAuth()) {
+ return true;
+ }
+
if (OC_User::isLoggedIn()) {
$user = OC_User::getUser();
OC_Util::setupFS($user);
diff --git a/lib/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php
index 4087c088f1a..531b0a807bf 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/private/connector/sabre/directory.php
@@ -54,34 +54,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
throw new \Sabre_DAV_Exception_Forbidden();
}
- if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
- return $this->createFileChunked($name, $data);
- }
- $newPath = $this->path . '/' . $name;
-
- // mark file as partial while uploading (ignored by the scanner)
- $partpath = $newPath . '.part';
-
- \OC\Files\Filesystem::file_put_contents($partpath, $data);
-
- // rename to correct path
- $renameOkay = \OC\Files\Filesystem::rename($partpath, $newPath);
- $fileExists = \OC\Files\Filesystem::file_exists($newPath);
- if ($renameOkay === false || $fileExists === false) {
- \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
- \OC\Files\Filesystem::unlink($partpath);
- throw new Sabre_DAV_Exception();
- }
-
- // allow sync clients to send the mtime along in a header
- $mtime = OC_Request::hasModificationTime();
- if ($mtime !== false) {
- if(\OC\Files\Filesystem::touch($newPath, $mtime)) {
- header('X-OC-MTime: accepted');
- }
- }
-
- return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
+ $path = $this->path . '/' . $name;
+ $node = new OC_Connector_Sabre_File($path);
+ return $node->put($data);
}
/**
@@ -235,39 +210,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function getProperties($properties) {
$props = parent::getProperties($properties);
if (in_array(self::GETETAG_PROPERTYNAME, $properties) && !isset($props[self::GETETAG_PROPERTYNAME])) {
- $props[self::GETETAG_PROPERTYNAME]
- = OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ $props[self::GETETAG_PROPERTYNAME] = $this->getETagPropertyForPath($this->path);
}
return $props;
}
- private function createFileChunked($name, $data)
- {
- $info = OC_FileChunking::decodeName($name);
- if (empty($info)) {
- throw new Sabre_DAV_Exception_NotImplemented();
- }
- $chunk_handler = new OC_FileChunking($info);
- $bytesWritten = $chunk_handler->store($info['index'], $data);
-
- //detect aborted upload
- if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
- if (isset($_SERVER['CONTENT_LENGTH'])) {
- $expected = $_SERVER['CONTENT_LENGTH'];
- if ($bytesWritten != $expected) {
- $chunk_handler->cleanup();
- throw new Sabre_DAV_Exception_BadRequest(
- 'expected filesize ' . $expected . ' got ' . $bytesWritten);
- }
- }
- }
-
- if ($chunk_handler->isComplete()) {
- $newPath = $this->path . '/' . $info['name'];
- $chunk_handler->file_assemble($newPath);
- return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
- }
-
- return null;
- }
}
diff --git a/lib/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 433b1148552..8ffec371e3f 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -28,7 +28,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*
* The data argument is a readable stream resource.
*
- * After a succesful put operation, you may choose to return an ETag. The
+ * After a successful 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.
*
@@ -45,8 +45,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return string|null
*/
public function put($data) {
-
- if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
+ $fs = $this->getFS();
+ if ($fs->file_exists($this->path) &&
+ !$fs->isUpdatable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
@@ -54,44 +55,59 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
if (\OC_Util::encryptedFiles()) {
throw new \Sabre_DAV_Exception_ServiceUnavailable();
}
-
+
+ // chunked handling
+ if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+ list(, $name) = \Sabre_DAV_URLUtil::splitPath($this->path);
+
+ $info = OC_FileChunking::decodeName($name);
+ if (empty($info)) {
+ throw new Sabre_DAV_Exception_NotImplemented();
+ }
+ $chunk_handler = new OC_FileChunking($info);
+ $chunk_handler->store($info['index'], $data);
+ if ($chunk_handler->isComplete()) {
+ $newPath = $this->path . '/' . $info['name'];
+ $chunk_handler->file_assemble($newPath);
+ return $this->getETagPropertyForPath($newPath);
+ }
+
+ return null;
+ }
+
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
- \OC\Files\Filesystem::file_put_contents($partpath, $data);
-
- //detect aborted upload
- if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
- if (isset($_SERVER['CONTENT_LENGTH'])) {
- $expected = $_SERVER['CONTENT_LENGTH'];
- $actual = \OC\Files\Filesystem::filesize($partpath);
- if ($actual != $expected) {
- \OC\Files\Filesystem::unlink($partpath);
- throw new Sabre_DAV_Exception_BadRequest(
- 'expected filesize ' . $expected . ' got ' . $actual);
- }
+ try {
+ $putOkay = $fs->file_put_contents($partpath, $data);
+ if ($putOkay === false) {
+ \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR);
+ $fs->unlink($partpath);
+ // because we have no clue about the cause we can only throw back a 500/Internal Server Error
+ throw new Sabre_DAV_Exception();
}
+ } catch (\OCP\Files\NotPermittedException $e) {
+ throw new Sabre_DAV_Exception_Forbidden();
}
// rename to correct path
- $renameOkay = \OC\Files\Filesystem::rename($partpath, $this->path);
- $fileExists = \OC\Files\Filesystem::file_exists($this->path);
+ $renameOkay = $fs->rename($partpath, $this->path);
+ $fileExists = $fs->file_exists($this->path);
if ($renameOkay === false || $fileExists === false) {
\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
- \OC\Files\Filesystem::unlink($partpath);
+ $fs->unlink($partpath);
throw new Sabre_DAV_Exception();
}
-
- //allow sync clients to send the mtime along in a header
+ // allow sync clients to send the mtime along in a header
$mtime = OC_Request::hasModificationTime();
if ($mtime !== false) {
- if (\OC\Files\Filesystem::touch($this->path, $mtime)) {
+ if($fs->touch($this->path, $mtime)) {
header('X-OC-MTime: accepted');
}
}
- return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ return $this->getETagPropertyForPath($this->path);
}
/**
@@ -101,7 +117,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*/
public function get() {
- //throw execption if encryption is disabled but files are still encrypted
+ //throw exception if encryption is disabled but files are still encrypted
if (\OC_Util::encryptedFiles()) {
throw new \Sabre_DAV_Exception_ServiceUnavailable();
} else {
@@ -144,7 +160,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*
* An ETag is a unique identifier representing the current version of the
* file. If the file changes, the ETag MUST change. The ETag is an
- * arbritrary string, but MUST be surrounded by double-quotes.
+ * arbitrary string, but MUST be surrounded by double-quotes.
*
* Return null if the ETag can not effectively be determined
*
diff --git a/lib/connector/sabre/locks.php b/lib/private/connector/sabre/locks.php
index 69496c15ada..69496c15ada 100644
--- a/lib/connector/sabre/locks.php
+++ b/lib/private/connector/sabre/locks.php
diff --git a/lib/connector/sabre/maintenanceplugin.php b/lib/private/connector/sabre/maintenanceplugin.php
index 2eda269afc2..2eda269afc2 100644
--- a/lib/connector/sabre/maintenanceplugin.php
+++ b/lib/private/connector/sabre/maintenanceplugin.php
diff --git a/lib/connector/sabre/node.php b/lib/private/connector/sabre/node.php
index 29b7f9e53a5..fa27abb381a 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/private/connector/sabre/node.php
@@ -33,6 +33,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
public static $ETagFunction = null;
/**
+ * is kept public to allow overwrite for unit testing
+ *
+ * @var \OC\Files\View
+ */
+ public $fileView;
+
+ /**
* The path to the current node
*
* @var string
@@ -207,7 +214,14 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
while( $row = $result->fetchRow()) {
$this->property_cache[$row['propertyname']] = $row['propertyvalue'];
}
- $this->property_cache[self::GETETAG_PROPERTYNAME] = $this->getETagPropertyForPath($this->path);
+
+ // Don't call the static getETagPropertyForPath, its result is not cached
+ $this->getFileinfoCache();
+ if ($this->fileinfo_cache['etag']) {
+ $this->property_cache[self::GETETAG_PROPERTYNAME] = '"'.$this->fileinfo_cache['etag'].'"';
+ } else {
+ $this->property_cache[self::GETETAG_PROPERTYNAME] = null;
+ }
}
// if the array was empty, we need to return everything
@@ -227,12 +241,18 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @param string $path Path of the file
* @return string|null Returns null if the ETag can not effectively be determined
*/
- static public function getETagPropertyForPath($path) {
- $data = \OC\Files\Filesystem::getFileInfo($path);
+ protected function getETagPropertyForPath($path) {
+ $data = $this->getFS()->getFileInfo($path);
if (isset($data['etag'])) {
return '"'.$data['etag'].'"';
}
return null;
}
+ protected function getFS() {
+ if (is_null($this->fileView)) {
+ $this->fileView = \OC\Files\Filesystem::getView();
+ }
+ return $this->fileView;
+ }
}
diff --git a/lib/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index 80c3840b99d..80c3840b99d 100644
--- a/lib/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
diff --git a/lib/connector/sabre/principal.php b/lib/private/connector/sabre/principal.php
index 59a96797c16..59a96797c16 100644
--- a/lib/connector/sabre/principal.php
+++ b/lib/private/connector/sabre/principal.php
diff --git a/lib/connector/sabre/quotaplugin.php b/lib/private/connector/sabre/quotaplugin.php
index ea2cb81d1f7..ea2cb81d1f7 100644
--- a/lib/connector/sabre/quotaplugin.php
+++ b/lib/private/connector/sabre/quotaplugin.php
diff --git a/lib/connector/sabre/request.php b/lib/private/connector/sabre/request.php
index d70c25c4e70..d70c25c4e70 100644
--- a/lib/connector/sabre/request.php
+++ b/lib/private/connector/sabre/request.php
diff --git a/lib/private/contactsmanager.php b/lib/private/contactsmanager.php
new file mode 100644
index 00000000000..fc6745b4505
--- /dev/null
+++ b/lib/private/contactsmanager.php
@@ -0,0 +1,145 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC {
+
+ class ContactsManager implements \OCP\Contacts\IManager {
+
+ /**
+ * This function is used to search and find contacts within the users address books.
+ * In case $pattern is empty all contacts will be returned.
+ *
+ * @param string $pattern which should match within the $searchProperties
+ * @param array $searchProperties defines the properties within the query pattern should match
+ * @param array $options - for future use. One should always have options!
+ * @return array of contacts which are arrays of key-value-pairs
+ */
+ public function search($pattern, $searchProperties = array(), $options = array()) {
+ $result = array();
+ foreach($this->address_books as $address_book) {
+ $r = $address_book->search($pattern, $searchProperties, $options);
+ $result = array_merge($result, $r);
+ }
+
+ return $result;
+ }
+
+ /**
+ * This function can be used to delete the contact identified by the given id
+ *
+ * @param object $id the unique identifier to a contact
+ * @param $address_book_key
+ * @return bool successful or not
+ */
+ public function delete($id, $address_book_key) {
+ if (!array_key_exists($address_book_key, $this->address_books))
+ return null;
+
+ $address_book = $this->address_books[$address_book_key];
+ if ($address_book->getPermissions() & \OCP\PERMISSION_DELETE)
+ return null;
+
+ return $address_book->delete($id);
+ }
+
+ /**
+ * This function is used to create a new contact if 'id' is not given or not present.
+ * Otherwise the contact will be updated by replacing the entire data set.
+ *
+ * @param array $properties this array if key-value-pairs defines a contact
+ * @param $address_book_key string to identify the address book in which the contact shall be created or updated
+ * @return array representing the contact just created or updated
+ */
+ public function createOrUpdate($properties, $address_book_key) {
+
+ if (!array_key_exists($address_book_key, $this->address_books))
+ return null;
+
+ $address_book = $this->address_books[$address_book_key];
+ if ($address_book->getPermissions() & \OCP\PERMISSION_CREATE)
+ return null;
+
+ return $address_book->createOrUpdate($properties);
+ }
+
+ /**
+ * Check if contacts are available (e.g. contacts app enabled)
+ *
+ * @return bool true if enabled, false if not
+ */
+ public function isEnabled() {
+ return !empty($this->address_books);
+ }
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ public function registerAddressBook(\OCP\IAddressBook $address_book) {
+ $this->address_books[$address_book->getKey()] = $address_book;
+ }
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ public function unregisterAddressBook(\OCP\IAddressBook $address_book) {
+ unset($this->address_books[$address_book->getKey()]);
+ }
+
+ /**
+ * @return array
+ */
+ public function getAddressBooks() {
+ $result = array();
+ foreach($this->address_books as $address_book) {
+ $result[$address_book->getKey()] = $address_book->getDisplayName();
+ }
+
+ return $result;
+ }
+
+ /**
+ * removes all registered address book instances
+ */
+ public function clear() {
+ $this->address_books = array();
+ }
+
+ /**
+ * @var \OCP\IAddressBook[] which holds all registered address books
+ */
+ private $address_books = array();
+
+ /**
+ * In order to improve lazy loading a closure can be registered which will be called in case
+ * address books are actually requested
+ *
+ * @param string $key
+ * @param \Closure $callable
+ */
+ function register($key, \Closure $callable)
+ {
+ //
+ //TODO: implement me
+ //
+ }
+ }
+}
diff --git a/lib/db.php b/lib/private/db.php
index 1e5d12649df..1e5d12649df 100644
--- a/lib/db.php
+++ b/lib/private/db.php
diff --git a/lib/db/adapter.php b/lib/private/db/adapter.php
index 6b31f37dd98..6b31f37dd98 100644
--- a/lib/db/adapter.php
+++ b/lib/private/db/adapter.php
diff --git a/lib/db/adapteroci8.php b/lib/private/db/adapteroci8.php
index bc226e979ec..bc226e979ec 100644
--- a/lib/db/adapteroci8.php
+++ b/lib/private/db/adapteroci8.php
diff --git a/lib/db/adapterpgsql.php b/lib/private/db/adapterpgsql.php
index 990d71c9f29..990d71c9f29 100644
--- a/lib/db/adapterpgsql.php
+++ b/lib/private/db/adapterpgsql.php
diff --git a/lib/db/adaptersqlite.php b/lib/private/db/adaptersqlite.php
index fa6d308ae32..fa6d308ae32 100644
--- a/lib/db/adaptersqlite.php
+++ b/lib/private/db/adaptersqlite.php
diff --git a/lib/db/adaptersqlsrv.php b/lib/private/db/adaptersqlsrv.php
index d0a67af28a7..d0a67af28a7 100644
--- a/lib/db/adaptersqlsrv.php
+++ b/lib/private/db/adaptersqlsrv.php
diff --git a/lib/db/connection.php b/lib/private/db/connection.php
index 2581969dbd0..2d3193a148a 100644
--- a/lib/db/connection.php
+++ b/lib/private/db/connection.php
@@ -12,7 +12,7 @@ use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\Common\EventManager;
-class Connection extends \Doctrine\DBAL\Connection {
+class Connection extends \Doctrine\DBAL\Connection implements \OCP\IDBConnection {
/**
* @var string $tablePrefix
*/
diff --git a/lib/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 8e76f46c78f..8e76f46c78f 100644
--- a/lib/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
diff --git a/lib/db/mdb2schemareader.php b/lib/private/db/mdb2schemareader.php
index b7128a2f176..b7128a2f176 100644
--- a/lib/db/mdb2schemareader.php
+++ b/lib/private/db/mdb2schemareader.php
diff --git a/lib/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php
index 21b43cbfe80..21b43cbfe80 100644
--- a/lib/db/mdb2schemawriter.php
+++ b/lib/private/db/mdb2schemawriter.php
diff --git a/lib/db/oracleconnection.php b/lib/private/db/oracleconnection.php
index e2fc4644f47..e2fc4644f47 100644
--- a/lib/db/oracleconnection.php
+++ b/lib/private/db/oracleconnection.php
diff --git a/lib/db/statementwrapper.php b/lib/private/db/statementwrapper.php
index b8da1afc0e5..b8da1afc0e5 100644
--- a/lib/db/statementwrapper.php
+++ b/lib/private/db/statementwrapper.php
diff --git a/lib/defaults.php b/lib/private/defaults.php
index 10813a3e8d8..4951c6f50ae 100644
--- a/lib/defaults.php
+++ b/lib/private/defaults.php
@@ -13,6 +13,7 @@ if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.
class OC_Defaults {
private $theme;
+ private $l;
private $defaultEntity;
private $defaultName;
@@ -24,7 +25,7 @@ class OC_Defaults {
private $defaultLogoClaim;
function __construct() {
- $l = OC_L10N::get('core');
+ $this->l = OC_L10N::get('core');
$this->defaultEntity = "ownCloud"; /* e.g. company name, used for footers and copyright notices */
$this->defaultName = "ownCloud"; /* short name, used when referring to the software */
@@ -32,7 +33,7 @@ class OC_Defaults {
$this->defaultBaseUrl = "http://owncloud.org";
$this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/";
$this->defaultDocBaseUrl = "http://doc.owncloud.org";
- $this->defaultSlogan = $l->t("web services under your control");
+ $this->defaultSlogan = $this->l->t("web services under your control");
$this->defaultLogoClaim = "";
if (class_exists("OC_Theme")) {
diff --git a/lib/eventsource.php b/lib/private/eventsource.php
index a83084d9251..a83084d9251 100644
--- a/lib/eventsource.php
+++ b/lib/private/eventsource.php
diff --git a/lib/filechunking.php b/lib/private/filechunking.php
index c0e3acbf1aa..0dfce696cda 100644
--- a/lib/filechunking.php
+++ b/lib/private/filechunking.php
@@ -29,7 +29,7 @@ class OC_FileChunking {
protected function getCache() {
if (!isset($this->cache)) {
- $this->cache = new OC_Cache_File();
+ $this->cache = new \OC\Cache\File();
}
return $this->cache;
}
diff --git a/lib/fileproxy.php b/lib/private/fileproxy.php
index 52ec79b4bdb..52ec79b4bdb 100644
--- a/lib/fileproxy.php
+++ b/lib/private/fileproxy.php
diff --git a/lib/fileproxy/fileoperations.php b/lib/private/fileproxy/fileoperations.php
index b2ff2e7e5e9..b2ff2e7e5e9 100644
--- a/lib/fileproxy/fileoperations.php
+++ b/lib/private/fileproxy/fileoperations.php
diff --git a/lib/files.php b/lib/private/files.php
index c705d2adb1a..c705d2adb1a 100644
--- a/lib/files.php
+++ b/lib/private/files.php
diff --git a/lib/files/cache/backgroundwatcher.php b/lib/private/files/cache/backgroundwatcher.php
index 923804f48d0..923804f48d0 100644
--- a/lib/files/cache/backgroundwatcher.php
+++ b/lib/private/files/cache/backgroundwatcher.php
diff --git a/lib/files/cache/cache.php b/lib/private/files/cache/cache.php
index e69733727af..364a50d377c 100644
--- a/lib/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -34,8 +34,8 @@ class Cache {
*/
private $storageCache;
- private $mimetypeIds = array();
- private $mimetypes = array();
+ private static $mimetypeIds = array();
+ private static $mimetypes = array();
/**
* @param \OC\Files\Storage\Storage|string $storage
@@ -64,30 +64,35 @@ class Cache {
* @return int
*/
public function getMimetypeId($mime) {
- if (!isset($this->mimetypeIds[$mime])) {
- $result = \OC_DB::executeAudited('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?', array($mime));
- if ($row = $result->fetchRow()) {
- $this->mimetypeIds[$mime] = $row['id'];
- } else {
- $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
- $this->mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
- }
- $this->mimetypes[$this->mimetypeIds[$mime]] = $mime;
+ if (empty(self::$mimetypeIds)) {
+ $this->loadMimetypes();
}
- return $this->mimetypeIds[$mime];
+
+ if (!isset(self::$mimetypeIds[$mime])) {
+ $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime));
+ self::$mimetypeIds[$mime] = \OC_DB::insertid('*PREFIX*mimetypes');
+ self::$mimetypes[self::$mimetypeIds[$mime]] = $mime;
+ }
+
+ return self::$mimetypeIds[$mime];
}
public function getMimetype($id) {
- if (!isset($this->mimetypes[$id])) {
- $sql = 'SELECT `mimetype` FROM `*PREFIX*mimetypes` WHERE `id` = ?';
- $result = \OC_DB::executeAudited($sql, array($id));
- if ($row = $result->fetchRow()) {
- $this->mimetypes[$id] = $row['mimetype'];
- } else {
- return null;
- }
+ if (empty(self::$mimetypes)) {
+ $this->loadMimetypes();
}
- return $this->mimetypes[$id];
+
+ return isset(self::$mimetypes[$id]) ? self::$mimetypes[$id] : null;
+ }
+
+ protected function loadMimetypes(){
+ $result = \OC_DB::executeAudited('SELECT `id`, `mimetype` FROM `*PREFIX*mimetypes`', array());
+ if ($result) {
+ while ($row = $result->fetchRow()) {
+ self::$mimetypeIds[$row['mimetype']] = $row['id'];
+ self::$mimetypes[$row['id']] = $row['mimetype'];
+ }
+ }
}
/**
diff --git a/lib/files/cache/legacy.php b/lib/private/files/cache/legacy.php
index 8eed1f67a5d..8eed1f67a5d 100644
--- a/lib/files/cache/legacy.php
+++ b/lib/private/files/cache/legacy.php
diff --git a/lib/files/cache/permissions.php b/lib/private/files/cache/permissions.php
index 2e2bdb20b78..2e2bdb20b78 100644
--- a/lib/files/cache/permissions.php
+++ b/lib/private/files/cache/permissions.php
diff --git a/lib/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 96f84609cf2..96f84609cf2 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
diff --git a/lib/files/cache/storage.php b/lib/private/files/cache/storage.php
index 8a9e47ca36d..8a9e47ca36d 100644
--- a/lib/files/cache/storage.php
+++ b/lib/private/files/cache/storage.php
diff --git a/lib/files/cache/updater.php b/lib/private/files/cache/updater.php
index 1f30173a8f8..1f30173a8f8 100644
--- a/lib/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
diff --git a/lib/files/cache/upgrade.php b/lib/private/files/cache/upgrade.php
index cfb9a117311..e3a46896cbf 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/private/files/cache/upgrade.php
@@ -192,7 +192,15 @@ class Upgrade {
*/
static function needUpgrade($user) {
$cacheVersion = (int)\OCP\Config::getUserValue($user, 'files', 'cache_version', 4);
- return $cacheVersion < 5;
+ if ($cacheVersion < 5) {
+ $legacy = new \OC\Files\Cache\Legacy($user);
+ if ($legacy->hasItems()) {
+ return true;
+ }
+ self::upgradeDone($user);
+ }
+
+ return false;
}
/**
diff --git a/lib/files/cache/watcher.php b/lib/private/files/cache/watcher.php
index 8bfd4602f3a..8bfd4602f3a 100644
--- a/lib/files/cache/watcher.php
+++ b/lib/private/files/cache/watcher.php
diff --git a/lib/files/filesystem.php b/lib/private/files/filesystem.php
index 10ec5c41d11..10ec5c41d11 100644
--- a/lib/files/filesystem.php
+++ b/lib/private/files/filesystem.php
diff --git a/lib/files/mapper.php b/lib/private/files/mapper.php
index 47abd4e52fe..47abd4e52fe 100644
--- a/lib/files/mapper.php
+++ b/lib/private/files/mapper.php
diff --git a/lib/files/mount/manager.php b/lib/private/files/mount/manager.php
index 4c432dcf724..4c432dcf724 100644
--- a/lib/files/mount/manager.php
+++ b/lib/private/files/mount/manager.php
diff --git a/lib/files/mount/mount.php b/lib/private/files/mount/mount.php
index 0ce2f5975c7..0ce2f5975c7 100644
--- a/lib/files/mount/mount.php
+++ b/lib/private/files/mount/mount.php
diff --git a/lib/files/node/file.php b/lib/private/files/node/file.php
index 75d5e0166b6..75d5e0166b6 100644
--- a/lib/files/node/file.php
+++ b/lib/private/files/node/file.php
diff --git a/lib/files/node/folder.php b/lib/private/files/node/folder.php
index 923f53821b2..923f53821b2 100644
--- a/lib/files/node/folder.php
+++ b/lib/private/files/node/folder.php
diff --git a/lib/files/node/node.php b/lib/private/files/node/node.php
index 063e2424a64..063e2424a64 100644
--- a/lib/files/node/node.php
+++ b/lib/private/files/node/node.php
diff --git a/lib/files/node/nonexistingfile.php b/lib/private/files/node/nonexistingfile.php
index d45076f7fee..d45076f7fee 100644
--- a/lib/files/node/nonexistingfile.php
+++ b/lib/private/files/node/nonexistingfile.php
diff --git a/lib/files/node/nonexistingfolder.php b/lib/private/files/node/nonexistingfolder.php
index 0346cbf1e21..0346cbf1e21 100644
--- a/lib/files/node/nonexistingfolder.php
+++ b/lib/private/files/node/nonexistingfolder.php
diff --git a/lib/files/node/root.php b/lib/private/files/node/root.php
index e3d58476e9c..e3d58476e9c 100644
--- a/lib/files/node/root.php
+++ b/lib/private/files/node/root.php
diff --git a/lib/files/storage/common.php b/lib/private/files/storage/common.php
index a5b79f0e967..a5b79f0e967 100644
--- a/lib/files/storage/common.php
+++ b/lib/private/files/storage/common.php
diff --git a/lib/files/storage/commontest.php b/lib/private/files/storage/commontest.php
index c3f1eb31955..c3f1eb31955 100644
--- a/lib/files/storage/commontest.php
+++ b/lib/private/files/storage/commontest.php
diff --git a/lib/files/storage/loader.php b/lib/private/files/storage/loader.php
index 2572ef443bc..2572ef443bc 100644
--- a/lib/files/storage/loader.php
+++ b/lib/private/files/storage/loader.php
diff --git a/lib/files/storage/local.php b/lib/private/files/storage/local.php
index 5209fabc30a..5209fabc30a 100644
--- a/lib/files/storage/local.php
+++ b/lib/private/files/storage/local.php
diff --git a/lib/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php
index ba5ac4191c5..ba5ac4191c5 100644
--- a/lib/files/storage/mappedlocal.php
+++ b/lib/private/files/storage/mappedlocal.php
diff --git a/lib/files/storage/storage.php b/lib/private/files/storage/storage.php
index b673bb9a32d..b673bb9a32d 100644
--- a/lib/files/storage/storage.php
+++ b/lib/private/files/storage/storage.php
diff --git a/lib/files/storage/temporary.php b/lib/private/files/storage/temporary.php
index d84dbda2e39..d84dbda2e39 100644
--- a/lib/files/storage/temporary.php
+++ b/lib/private/files/storage/temporary.php
diff --git a/lib/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php
index e2da8cf2e05..e2da8cf2e05 100644
--- a/lib/files/storage/wrapper/quota.php
+++ b/lib/private/files/storage/wrapper/quota.php
diff --git a/lib/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index 0336c27efa1..0336c27efa1 100644
--- a/lib/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
diff --git a/lib/files/stream/close.php b/lib/private/files/stream/close.php
index 80de3497c36..80de3497c36 100644
--- a/lib/files/stream/close.php
+++ b/lib/private/files/stream/close.php
diff --git a/lib/files/stream/dir.php b/lib/private/files/stream/dir.php
index 6ca884fc994..6ca884fc994 100644
--- a/lib/files/stream/dir.php
+++ b/lib/private/files/stream/dir.php
diff --git a/lib/files/stream/oc.php b/lib/private/files/stream/oc.php
index 88e7e062df9..88e7e062df9 100644
--- a/lib/files/stream/oc.php
+++ b/lib/private/files/stream/oc.php
diff --git a/lib/files/stream/quota.php b/lib/private/files/stream/quota.php
index 53d8a03d30f..53d8a03d30f 100644
--- a/lib/files/stream/quota.php
+++ b/lib/private/files/stream/quota.php
diff --git a/lib/files/stream/staticstream.php b/lib/private/files/stream/staticstream.php
index 45b1a7a81f8..45b1a7a81f8 100644
--- a/lib/files/stream/staticstream.php
+++ b/lib/private/files/stream/staticstream.php
diff --git a/lib/files/type/detection.php b/lib/private/files/type/detection.php
index 242a81cb5a4..242a81cb5a4 100644
--- a/lib/files/type/detection.php
+++ b/lib/private/files/type/detection.php
diff --git a/lib/files/type/templatemanager.php b/lib/private/files/type/templatemanager.php
index cd1536d2732..cd1536d2732 100644
--- a/lib/files/type/templatemanager.php
+++ b/lib/private/files/type/templatemanager.php
diff --git a/lib/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index 2cad7dd77bd..2cad7dd77bd 100644
--- a/lib/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
diff --git a/lib/files/view.php b/lib/private/files/view.php
index aa08a5f7cc9..aa08a5f7cc9 100644
--- a/lib/files/view.php
+++ b/lib/private/files/view.php
diff --git a/lib/geo.php b/lib/private/geo.php
index ed01ad0b616..ed01ad0b616 100644
--- a/lib/geo.php
+++ b/lib/private/geo.php
diff --git a/lib/group.php b/lib/private/group.php
index ba93dc129a1..ba93dc129a1 100644
--- a/lib/group.php
+++ b/lib/private/group.php
diff --git a/lib/group/backend.php b/lib/private/group/backend.php
index 2e17b5d0b7f..2e17b5d0b7f 100644
--- a/lib/group/backend.php
+++ b/lib/private/group/backend.php
diff --git a/lib/group/database.php b/lib/private/group/database.php
index d0974685ff6..d0974685ff6 100644
--- a/lib/group/database.php
+++ b/lib/private/group/database.php
diff --git a/lib/group/dummy.php b/lib/private/group/dummy.php
index 9516fd52ff8..9516fd52ff8 100644
--- a/lib/group/dummy.php
+++ b/lib/private/group/dummy.php
diff --git a/lib/group/example.php b/lib/private/group/example.php
index 3519b9ed92f..3519b9ed92f 100644
--- a/lib/group/example.php
+++ b/lib/private/group/example.php
diff --git a/lib/group/group.php b/lib/private/group/group.php
index bcd2419b309..bcd2419b309 100644
--- a/lib/group/group.php
+++ b/lib/private/group/group.php
diff --git a/lib/group/interface.php b/lib/private/group/interface.php
index 4ef3663837f..4ef3663837f 100644
--- a/lib/group/interface.php
+++ b/lib/private/group/interface.php
diff --git a/lib/group/manager.php b/lib/private/group/manager.php
index bf469d51d12..bf469d51d12 100644
--- a/lib/group/manager.php
+++ b/lib/private/group/manager.php
diff --git a/lib/helper.php b/lib/private/helper.php
index 66e7acb407a..a34640d8e36 100644
--- a/lib/helper.php
+++ b/lib/private/helper.php
@@ -41,8 +41,7 @@ class OC_Helper {
* Returns a url to the given app and file.
*/
public static function linkToRoute($route, $parameters = array()) {
- $urlLinkTo = OC::getRouter()->generate($route, $parameters);
- return $urlLinkTo;
+ return OC::$server->getURLGenerator()->linkToRoute($route, $parameters);
}
/**
@@ -56,32 +55,7 @@ class OC_Helper {
* Returns a url to the given app and file.
*/
public static function linkTo( $app, $file, $args = array() ) {
- if( $app != '' ) {
- $app_path = OC_App::getAppPath($app);
- // Check if the app is in the app folder
- if ($app_path && file_exists($app_path . '/' . $file)) {
- if (substr($file, -3) == 'php' || substr($file, -3) == 'css') {
- $urlLinkTo = OC::$WEBROOT . '/index.php/apps/' . $app;
- $urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
- } else {
- $urlLinkTo = OC_App::getAppWebPath($app) . '/' . $file;
- }
- } else {
- $urlLinkTo = OC::$WEBROOT . '/' . $app . '/' . $file;
- }
- } else {
- if (file_exists(OC::$SERVERROOT . '/core/' . $file)) {
- $urlLinkTo = OC::$WEBROOT . '/core/' . $file;
- } else {
- $urlLinkTo = OC::$WEBROOT . '/' . $file;
- }
- }
-
- if ($args && $query = http_build_query($args, '', '&')) {
- $urlLinkTo .= '?' . $query;
- }
-
- return $urlLinkTo;
+ return OC::$server->getURLGenerator()->linkTo($app, $file, $args);
}
/**
@@ -107,7 +81,7 @@ class OC_Helper {
* Returns a absolute url to the given app and file.
*/
public static function makeURLAbsolute($url) {
- return OC_Request::serverProtocol() . '://' . OC_Request::serverHost() . $url;
+ return OC::$server->getURLGenerator()->makeURLAbsolute($url);
}
/**
@@ -156,25 +130,7 @@ class OC_Helper {
* Returns the path to the image.
*/
public static function imagePath($app, $image) {
- // Read the selected theme from the config file
- $theme = OC_Util::getTheme();
-
- // Check if the app is in the app folder
- if (file_exists(OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
- } elseif (file_exists(OC_App::getAppPath($app) . "/img/$image")) {
- return OC_App::getAppWebPath($app) . "/img/$image";
- } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/$app/img/$image";
- } elseif (!empty($app) and file_exists(OC::$SERVERROOT . "/$app/img/$image")) {
- return OC::$WEBROOT . "/$app/img/$image";
- } elseif (file_exists(OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
- return OC::$WEBROOT . "/themes/$theme/core/img/$image";
- } elseif (file_exists(OC::$SERVERROOT . "/core/img/$image")) {
- return OC::$WEBROOT . "/core/img/$image";
- } else {
- throw new RuntimeException('image not found: image:' . $image . ' webroot:' . OC::$WEBROOT . ' serverroot:' . OC::$SERVERROOT);
- }
+ return OC::$server->getURLGenerator()->imagePath($app, $image);
}
/**
diff --git a/lib/hintexception.php b/lib/private/hintexception.php
index 3934ae2a4c2..3934ae2a4c2 100644
--- a/lib/hintexception.php
+++ b/lib/private/hintexception.php
diff --git a/lib/hook.php b/lib/private/hook.php
index 8516cf0dcff..8516cf0dcff 100644
--- a/lib/hook.php
+++ b/lib/private/hook.php
diff --git a/lib/hooks/basicemitter.php b/lib/private/hooks/basicemitter.php
index 9ffe1af2314..9ffe1af2314 100644
--- a/lib/hooks/basicemitter.php
+++ b/lib/private/hooks/basicemitter.php
diff --git a/lib/hooks/emitter.php b/lib/private/hooks/emitter.php
index 8e9074bad67..8e9074bad67 100644
--- a/lib/hooks/emitter.php
+++ b/lib/private/hooks/emitter.php
diff --git a/lib/hooks/forwardingemitter.php b/lib/private/hooks/forwardingemitter.php
index 1aacc4012e0..1aacc4012e0 100644
--- a/lib/hooks/forwardingemitter.php
+++ b/lib/private/hooks/forwardingemitter.php
diff --git a/lib/hooks/legacyemitter.php b/lib/private/hooks/legacyemitter.php
index a2d16ace9a7..a2d16ace9a7 100644
--- a/lib/hooks/legacyemitter.php
+++ b/lib/private/hooks/legacyemitter.php
diff --git a/lib/hooks/publicemitter.php b/lib/private/hooks/publicemitter.php
index e2371713ac3..e2371713ac3 100644
--- a/lib/hooks/publicemitter.php
+++ b/lib/private/hooks/publicemitter.php
diff --git a/lib/image.php b/lib/private/image.php
index 7761a3c7737..7761a3c7737 100644
--- a/lib/image.php
+++ b/lib/private/image.php
diff --git a/lib/installer.php b/lib/private/installer.php
index e082c7eeee9..e082c7eeee9 100644
--- a/lib/installer.php
+++ b/lib/private/installer.php
diff --git a/lib/json.php b/lib/private/json.php
index 6ba0b13806b..6ba0b13806b 100644
--- a/lib/json.php
+++ b/lib/private/json.php
diff --git a/lib/l10n.php b/lib/private/l10n.php
index f93443b886a..3e84c306dc2 100644
--- a/lib/l10n.php
+++ b/lib/private/l10n.php
@@ -25,12 +25,7 @@
/**
* This class is for i18n and l10n
*/
-class OC_L10N {
- /**
- * cached instances
- */
- protected static $instances=array();
-
+class OC_L10N implements \OCP\IL10N {
/**
* cache
*/
@@ -83,13 +78,10 @@ class OC_L10N {
* @return OC_L10N
*/
public static function get($app, $lang=null) {
- if(is_null($lang)) {
- if(!isset(self::$instances[$app])) {
- self::$instances[$app]=new OC_L10N($app);
- }
- return self::$instances[$app];
- }else{
- return new OC_L10N($app, $lang);
+ if (is_null($lang)) {
+ return OC::$server->getL10N($app);
+ } else {
+ return new \OC_L10N($app, $lang);
}
}
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php
new file mode 100644
index 00000000000..ba168872acd
--- /dev/null
+++ b/lib/private/l10n/factory.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC\L10N;
+
+/**
+ * TODO: Description
+ */
+class Factory {
+ /**
+ * cached instances
+ */
+ protected $instances = array();
+
+ /**
+ * get an L10N instance
+ * @param $app string
+ * @param $lang string|null
+ * @return OC_L10N
+ */
+ public function get($app) {
+ if (!isset($this->instances[$app])) {
+ $this->instances[$app] = new \OC_L10N($app);
+ }
+ return $this->instances[$app];
+ }
+
+}
diff --git a/lib/l10n/string.php b/lib/private/l10n/string.php
index 88c85b32e70..88c85b32e70 100644
--- a/lib/l10n/string.php
+++ b/lib/private/l10n/string.php
diff --git a/lib/private/legacy/cache.php b/lib/private/legacy/cache.php
new file mode 100644
index 00000000000..f915eb516b1
--- /dev/null
+++ b/lib/private/legacy/cache.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Cache extends \OC\Cache {
+} \ No newline at end of file
diff --git a/lib/private/legacy/cache/fileglobalgc.php b/lib/private/legacy/cache/fileglobalgc.php
new file mode 100644
index 00000000000..385f6406673
--- /dev/null
+++ b/lib/private/legacy/cache/fileglobalgc.php
@@ -0,0 +1,4 @@
+<?php
+
+class OC_Cache_FileGlobalGC extends OC\Cache\FileGlobalGC{
+}
diff --git a/lib/legacy/config.php b/lib/private/legacy/config.php
index 7e498013737..7e498013737 100644
--- a/lib/legacy/config.php
+++ b/lib/private/legacy/config.php
diff --git a/lib/legacy/filesystem.php b/lib/private/legacy/filesystem.php
index 34f92b357ca..34f92b357ca 100644
--- a/lib/legacy/filesystem.php
+++ b/lib/private/legacy/filesystem.php
diff --git a/lib/legacy/filesystemview.php b/lib/private/legacy/filesystemview.php
index d6bca62e06a..d6bca62e06a 100644
--- a/lib/legacy/filesystemview.php
+++ b/lib/private/legacy/filesystemview.php
diff --git a/lib/legacy/log.php b/lib/private/legacy/log.php
index 027cb89e97c..027cb89e97c 100644
--- a/lib/legacy/log.php
+++ b/lib/private/legacy/log.php
diff --git a/lib/legacy/preferences.php b/lib/private/legacy/preferences.php
index a663db7598b..a663db7598b 100644
--- a/lib/legacy/preferences.php
+++ b/lib/private/legacy/preferences.php
diff --git a/lib/legacy/updater.php b/lib/private/legacy/updater.php
index eea7bb129cf..eea7bb129cf 100644
--- a/lib/legacy/updater.php
+++ b/lib/private/legacy/updater.php
diff --git a/lib/log.php b/lib/private/log.php
index e0b9fe3c696..e0b9fe3c696 100644
--- a/lib/log.php
+++ b/lib/private/log.php
diff --git a/lib/log/errorhandler.php b/lib/private/log/errorhandler.php
index 69cb960de91..69cb960de91 100644
--- a/lib/log/errorhandler.php
+++ b/lib/private/log/errorhandler.php
diff --git a/lib/log/owncloud.php b/lib/private/log/owncloud.php
index d16b9537a16..d16b9537a16 100644
--- a/lib/log/owncloud.php
+++ b/lib/private/log/owncloud.php
diff --git a/lib/log/rotate.php b/lib/private/log/rotate.php
index bf23ad588b3..bf23ad588b3 100644
--- a/lib/log/rotate.php
+++ b/lib/private/log/rotate.php
diff --git a/lib/log/syslog.php b/lib/private/log/syslog.php
index c98deab7109..c98deab7109 100644
--- a/lib/log/syslog.php
+++ b/lib/private/log/syslog.php
diff --git a/lib/mail.php b/lib/private/mail.php
index b339b33e962..b339b33e962 100644
--- a/lib/mail.php
+++ b/lib/private/mail.php
diff --git a/lib/memcache/apc.php b/lib/private/memcache/apc.php
index 575ee4427db..575ee4427db 100644
--- a/lib/memcache/apc.php
+++ b/lib/private/memcache/apc.php
diff --git a/lib/memcache/apcu.php b/lib/private/memcache/apcu.php
index ccc1aa6e562..ccc1aa6e562 100644
--- a/lib/memcache/apcu.php
+++ b/lib/private/memcache/apcu.php
diff --git a/lib/memcache/cache.php b/lib/private/memcache/cache.php
index 0ad1cc7ec03..0ad1cc7ec03 100644
--- a/lib/memcache/cache.php
+++ b/lib/private/memcache/cache.php
diff --git a/lib/memcache/factory.php b/lib/private/memcache/factory.php
index fde7d947567..fde7d947567 100644
--- a/lib/memcache/factory.php
+++ b/lib/private/memcache/factory.php
diff --git a/lib/memcache/memcached.php b/lib/private/memcache/memcached.php
index 978e6c2eff1..978e6c2eff1 100644
--- a/lib/memcache/memcached.php
+++ b/lib/private/memcache/memcached.php
diff --git a/lib/memcache/xcache.php b/lib/private/memcache/xcache.php
index 33de30562f9..33de30562f9 100644
--- a/lib/memcache/xcache.php
+++ b/lib/private/memcache/xcache.php
diff --git a/lib/migrate.php b/lib/private/migrate.php
index 0b319177400..0b319177400 100644
--- a/lib/migrate.php
+++ b/lib/private/migrate.php
diff --git a/lib/migration/content.php b/lib/private/migration/content.php
index 4413d722731..4413d722731 100644
--- a/lib/migration/content.php
+++ b/lib/private/migration/content.php
diff --git a/lib/migration/provider.php b/lib/private/migration/provider.php
index 234ab3351f3..234ab3351f3 100644
--- a/lib/migration/provider.php
+++ b/lib/private/migration/provider.php
diff --git a/lib/mimetypes.list.php b/lib/private/mimetypes.list.php
index 8ab8ac81bd8..8ab8ac81bd8 100644
--- a/lib/mimetypes.list.php
+++ b/lib/private/mimetypes.list.php
diff --git a/lib/minimizer.php b/lib/private/minimizer.php
index db522de74dc..db522de74dc 100644
--- a/lib/minimizer.php
+++ b/lib/private/minimizer.php
diff --git a/lib/minimizer/css.php b/lib/private/minimizer/css.php
index 8d130572e2b..8d130572e2b 100644
--- a/lib/minimizer/css.php
+++ b/lib/private/minimizer/css.php
diff --git a/lib/minimizer/js.php b/lib/private/minimizer/js.php
index bd2d836deb0..bd2d836deb0 100644
--- a/lib/minimizer/js.php
+++ b/lib/private/minimizer/js.php
diff --git a/lib/private/navigationmanager.php b/lib/private/navigationmanager.php
new file mode 100644
index 00000000000..1f657b9ad80
--- /dev/null
+++ b/lib/private/navigationmanager.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * Manages the ownCloud navigation
+ */
+class NavigationManager implements \OCP\INavigationManager {
+ protected $entries = array();
+ protected $activeEntry;
+
+ /**
+ * Creates a new navigation entry
+ * @param array $entry containing: id, name, order, icon and href key
+ */
+ public function add(array $entry) {
+ $entry['active'] = false;
+ if(!isset($entry['icon'])) {
+ $entry['icon'] = '';
+ }
+ $this->entries[] = $entry;
+ }
+
+ /**
+ * @brief returns all the added Menu entries
+ * @return array of the added entries
+ */
+ public function getAll() {
+ return $this->entries;
+ }
+
+ /**
+ * @brief removes all the entries
+ */
+ public function clear() {
+ $this->entries = array();
+ }
+
+ /**
+ * Sets the current navigation entry of the currently running app
+ * @param string $id of the app entry to activate (from added $entry)
+ */
+ public function setActiveEntry($id) {
+ $this->activeEntry = $id;
+ }
+
+ /**
+ * @brief gets the active Menu entry
+ * @return string id or empty string
+ *
+ * This function returns the id of the active navigation entry (set by
+ * setActiveEntry
+ */
+ public function getActiveEntry() {
+ return $this->activeEntry;
+ }
+}
diff --git a/lib/notsquareexception.php b/lib/private/notsquareexception.php
index 03dba8fb25f..03dba8fb25f 100644
--- a/lib/notsquareexception.php
+++ b/lib/private/notsquareexception.php
diff --git a/lib/ocs.php b/lib/private/ocs.php
index 93e8931ce2e..93e8931ce2e 100644
--- a/lib/ocs.php
+++ b/lib/private/ocs.php
diff --git a/lib/ocs/cloud.php b/lib/private/ocs/cloud.php
index 2dd99319057..2dd99319057 100644
--- a/lib/ocs/cloud.php
+++ b/lib/private/ocs/cloud.php
diff --git a/lib/ocs/config.php b/lib/private/ocs/config.php
index f19121f4b2b..f19121f4b2b 100644
--- a/lib/ocs/config.php
+++ b/lib/private/ocs/config.php
diff --git a/lib/ocs/person.php b/lib/private/ocs/person.php
index 1c8210d0825..1c8210d0825 100644
--- a/lib/ocs/person.php
+++ b/lib/private/ocs/person.php
diff --git a/lib/ocs/privatedata.php b/lib/private/ocs/privatedata.php
index 4dfd0a6e66e..4dfd0a6e66e 100644
--- a/lib/ocs/privatedata.php
+++ b/lib/private/ocs/privatedata.php
diff --git a/lib/ocs/result.php b/lib/private/ocs/result.php
index 84f06fa01c7..84f06fa01c7 100644
--- a/lib/ocs/result.php
+++ b/lib/private/ocs/result.php
diff --git a/lib/ocsclient.php b/lib/private/ocsclient.php
index 58636f806be..e35556d92b8 100644
--- a/lib/ocsclient.php
+++ b/lib/private/ocsclient.php
@@ -36,7 +36,12 @@ class OC_OCSClient{
* to set it in the config file or it will fallback to the default
*/
private static function getAppStoreURL() {
- $url = OC_Config::getValue('appstoreurl', 'http://api.apps.owncloud.com/v1');
+ if(OC_Util::getEditionString()===''){
+ $default='http://api.apps.owncloud.com/v1';
+ }else{
+ $default='';
+ }
+ $url = OC_Config::getValue('appstoreurl', $default);
return($url);
}
diff --git a/lib/preferences.php b/lib/private/preferences.php
index 359d9a83589..359d9a83589 100644
--- a/lib/preferences.php
+++ b/lib/private/preferences.php
diff --git a/lib/preview.php b/lib/private/preview.php
index b40ba191fba..266f7795f12 100755
--- a/lib/preview.php
+++ b/lib/private/preview.php
@@ -42,6 +42,9 @@ class Preview {
private $scalingup;
//preview images object
+ /**
+ * @var \OC_Image
+ */
private $preview;
//preview providers
@@ -624,4 +627,4 @@ class Preview {
}
return false;
}
-} \ No newline at end of file
+}
diff --git a/lib/preview/image.php b/lib/private/preview/image.php
index 9aec967282d..9aec967282d 100644
--- a/lib/preview/image.php
+++ b/lib/private/preview/image.php
diff --git a/lib/preview/movies.php b/lib/private/preview/movies.php
index c318137ff0e..c318137ff0e 100644
--- a/lib/preview/movies.php
+++ b/lib/private/preview/movies.php
diff --git a/lib/preview/mp3.php b/lib/private/preview/mp3.php
index 1eed566315c..1eed566315c 100644
--- a/lib/preview/mp3.php
+++ b/lib/private/preview/mp3.php
diff --git a/lib/preview/office-cl.php b/lib/private/preview/office-cl.php
index 112909d6523..112909d6523 100644
--- a/lib/preview/office-cl.php
+++ b/lib/private/preview/office-cl.php
diff --git a/lib/preview/office-fallback.php b/lib/private/preview/office-fallback.php
index e69ab0ab8cb..e69ab0ab8cb 100644
--- a/lib/preview/office-fallback.php
+++ b/lib/private/preview/office-fallback.php
diff --git a/lib/preview/office.php b/lib/private/preview/office.php
index 5287bbd6ac1..5287bbd6ac1 100644
--- a/lib/preview/office.php
+++ b/lib/private/preview/office.php
diff --git a/lib/preview/pdf.php b/lib/private/preview/pdf.php
index cc974b68818..cc974b68818 100644
--- a/lib/preview/pdf.php
+++ b/lib/private/preview/pdf.php
diff --git a/lib/preview/provider.php b/lib/private/preview/provider.php
index e4a730bafc8..e4a730bafc8 100644
--- a/lib/preview/provider.php
+++ b/lib/private/preview/provider.php
diff --git a/lib/preview/svg.php b/lib/private/preview/svg.php
index b49e51720fa..b49e51720fa 100644
--- a/lib/preview/svg.php
+++ b/lib/private/preview/svg.php
diff --git a/lib/preview/txt.php b/lib/private/preview/txt.php
index 77e728eb364..77e728eb364 100644
--- a/lib/preview/txt.php
+++ b/lib/private/preview/txt.php
diff --git a/lib/preview/unknown.php b/lib/private/preview/unknown.php
index 9e6cd68d401..9e6cd68d401 100644
--- a/lib/preview/unknown.php
+++ b/lib/private/preview/unknown.php
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php
new file mode 100755
index 00000000000..ac9a866a75b
--- /dev/null
+++ b/lib/private/previewmanager.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller thomas.mueller@tmit.eu
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+namespace OC;
+
+use OCP\image;
+use OCP\IPreview;
+
+class PreviewManager implements IPreview {
+ /**
+ * @brief return a preview of a file
+ * @param string $file The path to the file where you want a thumbnail from
+ * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
+ * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
+ * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
+ * @return \OCP\Image
+ */
+ function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false)
+ {
+ $preview = new \OC\Preview('', '/', $file, $maxX, $maxY, $scaleUp);
+ return $preview->getPreview();
+ }
+
+ /**
+ * @brief returns true if the passed mime type is supported
+ * @param string $mimeType
+ * @return boolean
+ */
+ function isMimeSupported($mimeType = '*')
+ {
+ return \OC\Preview::isMimeSupported($mimeType);
+ }
+}
diff --git a/lib/request.php b/lib/private/request.php
index df33217f95d..df33217f95d 100755
--- a/lib/request.php
+++ b/lib/private/request.php
diff --git a/lib/response.php b/lib/private/response.php
index 674176d078b..674176d078b 100644
--- a/lib/response.php
+++ b/lib/private/response.php
diff --git a/lib/route.php b/lib/private/route.php
index 5901717c094..fb7da456b62 100644
--- a/lib/route.php
+++ b/lib/private/route.php
@@ -52,6 +52,14 @@ class OC_Route extends Route {
}
/**
+ * Specify PATCH as the method to use with this route
+ */
+ public function patch() {
+ $this->method('PATCH');
+ return $this;
+ }
+
+ /**
* Defaults to use for this route
*
* @param array $defaults The defaults
diff --git a/lib/router.php b/lib/private/router.php
index dbaca9e0d5d..dbaca9e0d5d 100644
--- a/lib/router.php
+++ b/lib/private/router.php
diff --git a/lib/search.php b/lib/private/search.php
index b9c75dfc333..b9c75dfc333 100644
--- a/lib/search.php
+++ b/lib/private/search.php
diff --git a/lib/search/provider.php b/lib/private/search/provider.php
index b617b9c5d94..b617b9c5d94 100644
--- a/lib/search/provider.php
+++ b/lib/private/search/provider.php
diff --git a/lib/search/provider/file.php b/lib/private/search/provider/file.php
index 9bd50931517..9bd50931517 100644
--- a/lib/search/provider/file.php
+++ b/lib/private/search/provider/file.php
diff --git a/lib/search/result.php b/lib/private/search/result.php
index 42275c2df11..42275c2df11 100644
--- a/lib/search/result.php
+++ b/lib/private/search/result.php
diff --git a/lib/private/server.php b/lib/private/server.php
new file mode 100644
index 00000000000..73a0cbd6ce6
--- /dev/null
+++ b/lib/private/server.php
@@ -0,0 +1,293 @@
+<?php
+
+namespace OC;
+
+use OC\AppFramework\Http\Request;
+use OC\AppFramework\Utility\SimpleContainer;
+use OC\Cache\UserCache;
+use OC\Files\Node\Root;
+use OC\Files\View;
+use OCP\IServerContainer;
+
+/**
+ * Class Server
+ * @package OC
+ *
+ * TODO: hookup all manager classes
+ */
+class Server extends SimpleContainer implements IServerContainer {
+
+ function __construct() {
+ $this->registerService('ContactsManager', function($c) {
+ return new ContactsManager();
+ });
+ $this->registerService('Request', function($c) {
+ if (isset($c['urlParams'])) {
+ $urlParams = $c['urlParams'];
+ } else {
+ $urlParams = array();
+ }
+
+ if (\OC::$session->exists('requesttoken')) {
+ $requesttoken = \OC::$session->get('requesttoken');
+ } else {
+ $requesttoken = false;
+ }
+
+
+ return new Request(
+ array(
+ 'get' => $_GET,
+ 'post' => $_POST,
+ 'files' => $_FILES,
+ 'server' => $_SERVER,
+ 'env' => $_ENV,
+ 'cookies' => $_COOKIE,
+ 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
+ ? $_SERVER['REQUEST_METHOD']
+ : null,
+ 'params' => $params,
+ 'urlParams' => $urlParams,
+ 'requesttoken' => $requesttoken,
+ )
+ );
+ });
+ $this->registerService('PreviewManager', function($c) {
+ return new PreviewManager();
+ });
+ $this->registerService('TagManager', function($c) {
+ $user = \OC_User::getUser();
+ return new TagManager($user);
+ });
+ $this->registerService('RootFolder', function($c) {
+ // TODO: get user and user manager from container as well
+ $user = \OC_User::getUser();
+ /** @var $c SimpleContainer */
+ $userManager = $c->query('UserManager');
+ $user = $userManager->get($user);
+ $manager = \OC\Files\Filesystem::getMountManager();
+ $view = new View();
+ return new Root($manager, $view, $user);
+ });
+ $this->registerService('UserManager', function($c) {
+ return new \OC\User\Manager();
+ });
+ $this->registerService('UserSession', function($c) {
+ /** @var $c SimpleContainer */
+ $manager = $c->query('UserManager');
+ $userSession = new \OC\User\Session($manager, \OC::$session);
+ $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
+ \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
+ });
+ $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
+ });
+ $userSession->listen('\OC\User', 'preDelete', function ($user) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
+ });
+ $userSession->listen('\OC\User', 'postDelete', function ($user) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
+ });
+ $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
+ });
+ $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
+ });
+ $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
+ \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
+ });
+ $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
+ /** @var $user \OC\User\User */
+ \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
+ });
+ $userSession->listen('\OC\User', 'logout', function () {
+ \OC_Hook::emit('OC_User', 'logout', array());
+ });
+ return $userSession;
+ });
+ $this->registerService('NavigationManager', function($c) {
+ return new \OC\NavigationManager();
+ });
+ $this->registerService('AllConfig', function($c) {
+ return new \OC\AllConfig();
+ });
+ $this->registerService('L10NFactory', function($c) {
+ return new \OC\L10N\Factory();
+ });
+ $this->registerService('URLGenerator', function($c) {
+ return new \OC\URLGenerator();
+ });
+ $this->registerService('AppHelper', function($c) {
+ return new \OC\AppHelper();
+ });
+ $this->registerService('UserCache', function($c) {
+ return new UserCache();
+ });
+ }
+
+ /**
+ * @return \OCP\Contacts\IManager
+ */
+ function getContactsManager() {
+ return $this->query('ContactsManager');
+ }
+
+ /**
+ * The current request object holding all information about the request
+ * currently being processed is returned from this method.
+ * In case the current execution was not initiated by a web request null is returned
+ *
+ * @return \OCP\IRequest|null
+ */
+ function getRequest() {
+ return $this->query('Request');
+ }
+
+ /**
+ * Returns the preview manager which can create preview images for a given file
+ *
+ * @return \OCP\IPreview
+ */
+ function getPreviewManager() {
+ return $this->query('PreviewManager');
+ }
+
+ /**
+ * Returns the tag manager which can get and set tags for different object types
+ *
+ * @see \OCP\ITagManager::load()
+ * @return \OCP\ITagManager
+ */
+ function getTagManager() {
+ return $this->query('TagManager');
+ }
+
+ /**
+ * Returns the root folder of ownCloud's data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getRootFolder() {
+ return $this->query('RootFolder');
+ }
+
+ /**
+ * Returns a view to ownCloud's files folder
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getUserFolder() {
+
+ $dir = '/files';
+ $root = $this->getRootFolder();
+ $folder = null;
+ if(!$root->nodeExists($dir)) {
+ $folder = $root->newFolder($dir);
+ } else {
+ $folder = $root->get($dir);
+ }
+ return $folder;
+ }
+
+ /**
+ * Returns an app-specific view in ownClouds data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getAppFolder() {
+
+ $dir = '/' . \OC_App::getCurrentApp();
+ $root = $this->getRootFolder();
+ $folder = null;
+ if(!$root->nodeExists($dir)) {
+ $folder = $root->newFolder($dir);
+ } else {
+ $folder = $root->get($dir);
+ }
+ return $folder;
+ }
+
+ /**
+ * @return \OC\User\Manager
+ */
+ function getUserManager() {
+ return $this->query('UserManager');
+ }
+
+ /**
+ * @return \OC\User\Session
+ */
+ function getUserSession() {
+ return $this->query('UserSession');
+ }
+
+ /**
+ * @return \OC\NavigationManager
+ */
+ function getNavigationManager() {
+ return $this->query('NavigationManager');
+ }
+
+ /**
+ * @return \OC\Config
+ */
+ function getConfig() {
+ return $this->query('AllConfig');
+ }
+
+ /**
+ * get an L10N instance
+ * @param $app string appid
+ * @return \OC_L10N
+ */
+ function getL10N($app) {
+ return $this->query('L10NFactory')->get($app);
+ }
+
+ /**
+ * @return \OC\URLGenerator
+ */
+ function getURLGenerator() {
+ return $this->query('URLGenerator');
+ }
+
+ /**
+ * @return \OC\Helper
+ */
+ function getHelper() {
+ return $this->query('AppHelper');
+ }
+
+ /**
+ * Returns an ICache instance
+ *
+ * @return \OCP\ICache
+ */
+ function getCache() {
+ return $this->query('UserCache');
+ }
+
+ /**
+ * Returns the current session
+ *
+ * @return \OCP\ISession
+ */
+ function getSession() {
+ return \OC::$session;
+ }
+
+ /**
+ * Returns the current session
+ *
+ * @return \OCP\IDBConnection
+ */
+ function getDatabaseConnection() {
+ return \OC_DB::getConnection();
+ }
+}
diff --git a/lib/session/internal.php b/lib/private/session/internal.php
index 60aecccc8aa..60aecccc8aa 100644
--- a/lib/session/internal.php
+++ b/lib/private/session/internal.php
diff --git a/lib/session/memory.php b/lib/private/session/memory.php
index c148ff4b9b9..c148ff4b9b9 100644
--- a/lib/session/memory.php
+++ b/lib/private/session/memory.php
diff --git a/lib/session/session.php b/lib/private/session/session.php
index 55515f57a87..c55001eccac 100644
--- a/lib/session/session.php
+++ b/lib/private/session/session.php
@@ -8,7 +8,7 @@
namespace OC\Session;
-abstract class Session implements \ArrayAccess {
+abstract class Session implements \ArrayAccess, \OCP\ISession {
/**
* $name serves as a namespace for the session keys
*
diff --git a/lib/setup.php b/lib/private/setup.php
index 6bf3c88370f..6bf3c88370f 100644
--- a/lib/setup.php
+++ b/lib/private/setup.php
diff --git a/lib/setup/abstractdatabase.php b/lib/private/setup/abstractdatabase.php
index 0beada7bd29..0beada7bd29 100644
--- a/lib/setup/abstractdatabase.php
+++ b/lib/private/setup/abstractdatabase.php
diff --git a/lib/setup/mssql.php b/lib/private/setup/mssql.php
index b8329f99079..b8329f99079 100644
--- a/lib/setup/mssql.php
+++ b/lib/private/setup/mssql.php
diff --git a/lib/setup/mysql.php b/lib/private/setup/mysql.php
index d97b6d2602f..d97b6d2602f 100644
--- a/lib/setup/mysql.php
+++ b/lib/private/setup/mysql.php
diff --git a/lib/setup/oci.php b/lib/private/setup/oci.php
index 326d7a00531..326d7a00531 100644
--- a/lib/setup/oci.php
+++ b/lib/private/setup/oci.php
diff --git a/lib/setup/postgresql.php b/lib/private/setup/postgresql.php
index 89d328ada19..89d328ada19 100644
--- a/lib/setup/postgresql.php
+++ b/lib/private/setup/postgresql.php
diff --git a/lib/setup/sqlite.php b/lib/private/setup/sqlite.php
index fd4df792d62..fd4df792d62 100644
--- a/lib/setup/sqlite.php
+++ b/lib/private/setup/sqlite.php
diff --git a/lib/subadmin.php b/lib/private/subadmin.php
index 8cda7240ac9..8cda7240ac9 100644
--- a/lib/subadmin.php
+++ b/lib/private/subadmin.php
diff --git a/lib/private/tagmanager.php b/lib/private/tagmanager.php
new file mode 100644
index 00000000000..9a371a11253
--- /dev/null
+++ b/lib/private/tagmanager.php
@@ -0,0 +1,68 @@
+<?php
+/**
+* ownCloud
+*
+* @author Thomas Tanghus
+* @copyright 2013 Thomas Tanghus <thomas@tanghus.net>
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Factory class creating instances of \OCP\ITags
+ *
+ * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
+ * anything else that is either parsed from a vobject or that the user chooses
+ * to add.
+ * Tag names are not case-sensitive, but will be saved with the case they
+ * are entered in. If a user already has a tag 'family' for a type, and
+ * tries to add a tag named 'Family' it will be silently ignored.
+ */
+
+namespace OC;
+
+class TagManager implements \OCP\ITagManager {
+
+ /**
+ * User
+ *
+ * @var string
+ */
+ private $user = null;
+
+ /**
+ * Constructor.
+ *
+ * @param string $user The user whos data the object will operate on.
+ */
+ public function __construct($user) {
+
+ $this->user = $user;
+
+ }
+
+ /**
+ * Create a new \OCP\ITags instance and load tags from db.
+ *
+ * @see \OCP\ITags
+ * @param string $type The type identifier e.g. 'contact' or 'event'.
+ * @param array $defaultTags An array of default tags to be used if none are stored.
+ * @return \OCP\ITags
+ */
+ public function load($type, $defaultTags=array()) {
+ return new Tags($this->user, $type, $defaultTags);
+ }
+
+} \ No newline at end of file
diff --git a/lib/private/tags.php b/lib/private/tags.php
new file mode 100644
index 00000000000..9fdb35a7d6e
--- /dev/null
+++ b/lib/private/tags.php
@@ -0,0 +1,642 @@
+<?php
+/**
+* ownCloud
+*
+* @author Thomas Tanghus
+* @copyright 2012-2013 Thomas Tanghus <thomas@tanghus.net>
+* @copyright 2012 Bart Visscher bartv@thisnet.nl
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Class for easily tagging objects by their id
+ *
+ * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
+ * anything else that is either parsed from a vobject or that the user chooses
+ * to add.
+ * Tag names are not case-sensitive, but will be saved with the case they
+ * are entered in. If a user already has a tag 'family' for a type, and
+ * tries to add a tag named 'Family' it will be silently ignored.
+ */
+
+namespace OC;
+
+class Tags implements \OCP\ITags {
+
+ /**
+ * Tags
+ *
+ * @var array
+ */
+ private $tags = array();
+
+ /**
+ * Used for storing objectid/categoryname pairs while rescanning.
+ *
+ * @var array
+ */
+ private static $relations = array();
+
+ /**
+ * Type
+ *
+ * @var string
+ */
+ private $type = null;
+
+ /**
+ * User
+ *
+ * @var string
+ */
+ private $user = null;
+
+ const TAG_TABLE = '*PREFIX*vcategory';
+ const RELATION_TABLE = '*PREFIX*vcategory_to_object';
+
+ const TAG_FAVORITE = '_$!<Favorite>!$_';
+
+ /**
+ * Constructor.
+ *
+ * @param string $user The user whos data the object will operate on.
+ */
+ public function __construct($user, $type, $defaultTags = array()) {
+ $this->user = $user;
+ $this->type = $type;
+ $this->loadTags($defaultTags);
+ }
+
+ /**
+ * Load tags from db.
+ *
+ * @param string $type The type identifier e.g. 'contact' or 'event'.
+ * @param array $defaultTags An array of default tags to be used if none are stored.
+ */
+ protected function loadTags($defaultTags=array()) {
+ $this->tags = array();
+ $result = null;
+ $sql = 'SELECT `id`, `category` FROM `' . self::TAG_TABLE . '` '
+ . 'WHERE `uid` = ? AND `type` = ? ORDER BY `category`';
+ try {
+ $stmt = \OCP\DB::prepare($sql);
+ $result = $stmt->execute(array($this->user, $this->type));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+
+ if(!is_null($result)) {
+ while( $row = $result->fetchRow()) {
+ $this->tags[$row['id']] = $row['category'];
+ }
+ }
+
+ if(count($defaultTags) > 0 && count($this->tags) === 0) {
+ $this->addMultiple($defaultTags, true);
+ }
+ \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true),
+ \OCP\Util::DEBUG);
+
+ }
+
+ /**
+ * Check if any tags are saved for this type and user.
+ *
+ * @return boolean.
+ */
+ public function isEmpty() {
+ $sql = 'SELECT COUNT(*) FROM `' . self::TAG_TABLE . '` '
+ . 'WHERE `uid` = ? AND `type` = ?';
+ try {
+ $stmt = \OCP\DB::prepare($sql);
+ $result = $stmt->execute(array($this->user, $this->type));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ return false;
+ }
+ return ((int)$result->fetchOne() === 0);
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ }
+
+ /**
+ * Get the tags for a specific user.
+ *
+ * This returns an array with id/name maps:
+ * [
+ * ['id' => 0, 'name' = 'First tag'],
+ * ['id' => 1, 'name' = 'Second tag'],
+ * ]
+ *
+ * @return array
+ */
+ public function getTags() {
+ if(!count($this->tags)) {
+ return array();
+ }
+
+ $tags = array_values($this->tags);
+ uasort($tags, 'strnatcasecmp');
+ $tagMap = array();
+
+ foreach($tags as $tag) {
+ if($tag !== self::TAG_FAVORITE) {
+ $tagMap[] = array(
+ 'id' => $this->array_searchi($tag, $this->tags),
+ 'name' => $tag
+ );
+ }
+ }
+ return $tagMap;
+
+ }
+
+ /**
+ * Get the a list if items tagged with $tag.
+ *
+ * Throws an exception if the tag could not be found.
+ *
+ * @param string|integer $tag Tag id or name.
+ * @return array An array of object ids or false on error.
+ */
+ public function getIdsForTag($tag) {
+ $result = null;
+ if(is_numeric($tag)) {
+ $tagId = $tag;
+ } elseif(is_string($tag)) {
+ $tag = trim($tag);
+ $tagId = $this->array_searchi($tag, $this->tags);
+ }
+
+ if($tagId === false) {
+ $l10n = \OC_L10N::get('core');
+ throw new \Exception(
+ $l10n->t('Could not find category "%s"', $tag)
+ );
+ }
+
+ $ids = array();
+ $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE
+ . '` WHERE `categoryid` = ?';
+
+ try {
+ $stmt = \OCP\DB::prepare($sql);
+ $result = $stmt->execute(array($tagId));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ return false;
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+
+ if(!is_null($result)) {
+ while( $row = $result->fetchRow()) {
+ $ids[] = (int)$row['objid'];
+ }
+ }
+
+ return $ids;
+ }
+
+ /**
+ * Checks whether a tag is already saved.
+ *
+ * @param string $name The name to check for.
+ * @return bool
+ */
+ public function hasTag($name) {
+ return $this->in_arrayi($name, $this->tags);
+ }
+
+ /**
+ * Add a new tag.
+ *
+ * @param string $name A string with a name of the tag
+ * @return int the id of the added tag or false if it already exists.
+ */
+ public function add($name) {
+ $name = trim($name);
+
+ if($this->hasTag($name)) {
+ \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', \OCP\Util::DEBUG);
+ return false;
+ }
+ try {
+ $result = \OCP\DB::insertIfNotExist(
+ self::TAG_TABLE,
+ array(
+ 'uid' => $this->user,
+ 'type' => $this->type,
+ 'category' => $name,
+ )
+ );
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ return false;
+ } elseif((int)$result === 0) {
+ \OCP\Util::writeLog('core', __METHOD__.', Tag already exists: ' . $name, \OCP\Util::DEBUG);
+ return false;
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ $id = \OCP\DB::insertid(self::TAG_TABLE);
+ \OCP\Util::writeLog('core', __METHOD__.', id: ' . $id, \OCP\Util::DEBUG);
+ $this->tags[$id] = $name;
+ return $id;
+ }
+
+ /**
+ * Rename tag.
+ *
+ * @param string $from The name of the existing tag
+ * @param string $to The new name of the tag.
+ * @return bool
+ */
+ public function rename($from, $to) {
+ $from = trim($from);
+ $to = trim($to);
+ $id = $this->array_searchi($from, $this->tags);
+ if($id === false) {
+ \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', \OCP\Util::DEBUG);
+ return false;
+ }
+
+ $sql = 'UPDATE `' . self::TAG_TABLE . '` SET `category` = ? '
+ . 'WHERE `uid` = ? AND `type` = ? AND `id` = ?';
+ try {
+ $stmt = \OCP\DB::prepare($sql);
+ $result = $stmt->execute(array($to, $this->user, $this->type, $id));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ return false;
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ $this->tags[$id] = $to;
+ return true;
+ }
+
+ /**
+ * Add a list of new tags.
+ *
+ * @param string[] $names A string with a name or an array of strings containing
+ * the name(s) of the to add.
+ * @param bool $sync When true, save the tags
+ * @param int|null $id int Optional object id to add to this|these tag(s)
+ * @return bool Returns false on error.
+ */
+ public function addMultiple($names, $sync=false, $id = null) {
+ if(!is_array($names)) {
+ $names = array($names);
+ }
+ $names = array_map('trim', $names);
+ $newones = array();
+ foreach($names as $name) {
+ if(($this->in_arrayi(
+ $name, $this->tags) == false) && $name !== '') {
+ $newones[] = $name;
+ }
+ if(!is_null($id) ) {
+ // Insert $objectid, $categoryid pairs if not exist.
+ self::$relations[] = array('objid' => $id, 'tag' => $name);
+ }
+ }
+ $this->tags = array_merge($this->tags, $newones);
+ if($sync === true) {
+ $this->save();
+ }
+
+ return true;
+ }
+
+ /**
+ * Save the list of tags and their object relations
+ */
+ protected function save() {
+ if(is_array($this->tags)) {
+ foreach($this->tags as $tag) {
+ try {
+ \OCP\DB::insertIfNotExist(self::TAG_TABLE,
+ array(
+ 'uid' => $this->user,
+ 'type' => $this->type,
+ 'category' => $tag,
+ ));
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+ }
+ // reload tags to get the proper ids.
+ $this->loadTags();
+ // Loop through temporarily cached objectid/tagname pairs
+ // and save relations.
+ $tags = $this->tags;
+ // For some reason this is needed or array_search(i) will return 0..?
+ ksort($tags);
+ foreach(self::$relations as $relation) {
+ $tagId = $this->array_searchi($relation['tag'], $tags);
+ \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, \OCP\Util::DEBUG);
+ if($tagId) {
+ try {
+ \OCP\DB::insertIfNotExist(self::RELATION_TABLE,
+ array(
+ 'objid' => $relation['objid'],
+ 'categoryid' => $tagId,
+ 'type' => $this->type,
+ ));
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+ }
+ }
+ self::$relations = array(); // reset
+ } else {
+ \OCP\Util::writeLog('core', __METHOD__.', $this->tags is not an array! '
+ . print_r($this->tags, true), \OCP\Util::ERROR);
+ }
+ }
+
+ /**
+ * Delete tags and tag/object relations for a user.
+ *
+ * For hooking up on post_deleteUser
+ *
+ * @param array
+ */
+ public static function post_deleteUser($arguments) {
+ // Find all objectid/tagId pairs.
+ $result = null;
+ try {
+ $stmt = \OCP\DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` '
+ . 'WHERE `uid` = ?');
+ $result = $stmt->execute(array($arguments['uid']));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+
+ if(!is_null($result)) {
+ try {
+ $stmt = \OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
+ . 'WHERE `categoryid` = ?');
+ while( $row = $result->fetchRow()) {
+ try {
+ $stmt->execute(array($row['id']));
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ }
+ }
+ try {
+ $stmt = \OCP\DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` '
+ . 'WHERE `uid` = ?');
+ $result = $stmt->execute(array($arguments['uid']));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__ . ', exception: '
+ . $e->getMessage(), \OCP\Util::ERROR);
+ }
+ }
+
+ /**
+ * Delete tag/object relations from the db
+ *
+ * @param array $ids The ids of the objects
+ * @return boolean Returns false on error.
+ */
+ public function purgeObjects(array $ids) {
+ if(count($ids) === 0) {
+ // job done ;)
+ return true;
+ }
+ $updates = $ids;
+ try {
+ $query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
+ $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
+ $query .= 'AND `type`= ?';
+ $updates[] = $this->type;
+ $stmt = \OCP\DB::prepare($query);
+ $result = $stmt->execute($updates);
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ return false;
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Get favorites for an object type
+ *
+ * @return array An array of object ids.
+ */
+ public function getFavorites() {
+ try {
+ return $this->getIdsForTag(self::TAG_FAVORITE);
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
+ \OCP\Util::ERROR);
+ return array();
+ }
+ }
+
+ /**
+ * Add an object to favorites
+ *
+ * @param int $objid The id of the object
+ * @return boolean
+ */
+ public function addToFavorites($objid) {
+ if(!$this->hasTag(self::TAG_FAVORITE)) {
+ $this->add(self::TAG_FAVORITE, true);
+ }
+ return $this->tagAs($objid, self::TAG_FAVORITE, $this->type);
+ }
+
+ /**
+ * Remove an object from favorites
+ *
+ * @param int $objid The id of the object
+ * @return boolean
+ */
+ public function removeFromFavorites($objid) {
+ return $this->unTag($objid, self::TAG_FAVORITE, $this->type);
+ }
+
+ /**
+ * Creates a tag/object relation.
+ *
+ * @param int $objid The id of the object
+ * @param int|string $tag The id or name of the tag
+ * @return boolean Returns false on database error.
+ */
+ public function tagAs($objid, $tag) {
+ if(is_string($tag) && !is_numeric($tag)) {
+ $tag = trim($tag);
+ if(!$this->hasTag($tag)) {
+ $this->add($tag, true);
+ }
+ $tagId = $this->array_searchi($tag, $this->tags);
+ } else {
+ $tagId = $tag;
+ }
+ try {
+ \OCP\DB::insertIfNotExist(self::RELATION_TABLE,
+ array(
+ 'objid' => $objid,
+ 'categoryid' => $tagId,
+ 'type' => $this->type,
+ ));
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Delete single tag/object relation from the db
+ *
+ * @param int $objid The id of the object
+ * @param int|string $tag The id or name of the tag
+ * @return boolean
+ */
+ public function unTag($objid, $tag) {
+ if(is_string($tag) && !is_numeric($tag)) {
+ $tag = trim($tag);
+ $tagId = $this->array_searchi($tag, $this->tags);
+ } else {
+ $tagId = $tag;
+ }
+
+ try {
+ $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
+ . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
+ $stmt = \OCP\DB::prepare($sql);
+ $stmt->execute(array($objid, $tagId, $this->type));
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Delete tags from the
+ *
+ * @param string[] $names An array of tags to delete
+ * @return bool Returns false on error
+ */
+ public function delete($names) {
+ if(!is_array($names)) {
+ $names = array($names);
+ }
+
+ $names = array_map('trim', $names);
+
+ \OCP\Util::writeLog('core', __METHOD__ . ', before: '
+ . print_r($this->tags, true), \OCP\Util::DEBUG);
+ foreach($names as $name) {
+ $id = null;
+
+ if($this->hasTag($name)) {
+ $id = $this->array_searchi($name, $this->tags);
+ unset($this->tags[$id]);
+ }
+ try {
+ $stmt = \OCP\DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` WHERE '
+ . '`uid` = ? AND `type` = ? AND `category` = ?');
+ $result = $stmt->execute(array($this->user, $this->type, $name));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__ . ', exception: '
+ . $e->getMessage(), \OCP\Util::ERROR);
+ return false;
+ }
+ if(!is_null($id) && $id !== false) {
+ try {
+ $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
+ . 'WHERE `categoryid` = ?';
+ $stmt = \OCP\DB::prepare($sql);
+ $result = $stmt->execute(array($id));
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('core',
+ __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ } catch(\Exception $e) {
+ \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ \OCP\Util::ERROR);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ // case-insensitive in_array
+ private function in_arrayi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
+ return in_array(strtolower($needle), array_map('strtolower', $haystack));
+ }
+
+ // case-insensitive array_search
+ private function array_searchi($needle, $haystack) {
+ if(!is_array($haystack)) {
+ return false;
+ }
+ return array_search(strtolower($needle), array_map('strtolower', $haystack));
+ }
+}
diff --git a/lib/template.php b/lib/private/template.php
index 9b2c1211e61..9b2c1211e61 100644
--- a/lib/template.php
+++ b/lib/private/template.php
diff --git a/lib/template/base.php b/lib/private/template/base.php
index 88941bc7132..88941bc7132 100644
--- a/lib/template/base.php
+++ b/lib/private/template/base.php
diff --git a/lib/template/cssresourcelocator.php b/lib/private/template/cssresourcelocator.php
index 8e7831ca549..8e7831ca549 100644
--- a/lib/template/cssresourcelocator.php
+++ b/lib/private/template/cssresourcelocator.php
diff --git a/lib/template/functions.php b/lib/private/template/functions.php
index 501f8081bff..0aa2b27b96b 100644
--- a/lib/template/functions.php
+++ b/lib/private/template/functions.php
@@ -85,22 +85,51 @@ function human_file_size( $bytes ) {
return OC_Helper::humanFileSize( $bytes );
}
-function relative_modified_date($timestamp) {
+/**
+ * @brief Strips the timestamp of its time value
+ * @param int $timestamp UNIX timestamp to strip
+ * @return $timestamp without time value
+ */
+function strip_time($timestamp){
+ $date = new \DateTime("@{$timestamp}");
+ $date->setTime(0, 0, 0);
+ return intval($date->format('U'));
+}
+
+/**
+ * @brief Formats timestamp relatively to the current time using
+ * a human-friendly format like "x minutes ago" or "yesterday"
+ * @param int $timestamp timestamp to format
+ * @param int $fromTime timestamp to compare from, defaults to current time
+ * @param bool $dateOnly whether to strip time information
+ * @return formatted timestamp
+ */
+function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false) {
$l=OC_L10N::get('lib');
- $timediff = time() - $timestamp;
+ if (!isset($fromTime) || $fromTime === null){
+ $fromTime = time();
+ }
+ if ($dateOnly){
+ $fromTime = strip_time($fromTime);
+ $timestamp = strip_time($timestamp);
+ }
+ $timediff = $fromTime - $timestamp;
$diffminutes = round($timediff/60);
$diffhours = round($diffminutes/60);
$diffdays = round($diffhours/24);
$diffmonths = round($diffdays/31);
- if($timediff < 60) { return $l->t('seconds ago'); }
- else if($timediff < 3600) { return $l->n('%n minute ago', '%n minutes ago', $diffminutes); }
- else if($timediff < 86400) { return $l->n('%n hour ago', '%n hours ago', $diffhours); }
- else if((date('G')-$diffhours) > 0) { return $l->t('today'); }
- else if((date('G')-$diffhours) > -24) { return $l->t('yesterday'); }
+ if(!$dateOnly && $timediff < 60) { return $l->t('seconds ago'); }
+ else if(!$dateOnly && $timediff < 3600) { return $l->n('%n minute ago', '%n minutes ago', $diffminutes); }
+ else if(!$dateOnly && $timediff < 86400) { return $l->n('%n hour ago', '%n hours ago', $diffhours); }
+ else if((date('G', $fromTime)-$diffhours) >= 0) { return $l->t('today'); }
+ else if((date('G', $fromTime)-$diffhours) >= -24) { return $l->t('yesterday'); }
+ // 86400 * 31 days = 2678400
else if($timediff < 2678400) { return $l->n('%n day go', '%n days ago', $diffdays); }
+ // 86400 * 60 days = 518400
else if($timediff < 5184000) { return $l->t('last month'); }
- else if((date('n')-$diffmonths) > 0) { return $l->n('%n month ago', '%n months ago', $diffmonths); }
+ else if((date('n', $fromTime)-$diffmonths) > 0) { return $l->n('%n month ago', '%n months ago', $diffmonths); }
+ // 86400 * 365.25 days * 2 = 63113852
else if($timediff < 63113852) { return $l->t('last year'); }
else { return $l->t('years ago'); }
}
diff --git a/lib/template/jsresourcelocator.php b/lib/private/template/jsresourcelocator.php
index f8fe3817ce6..f8fe3817ce6 100644
--- a/lib/template/jsresourcelocator.php
+++ b/lib/private/template/jsresourcelocator.php
diff --git a/lib/template/resourcelocator.php b/lib/private/template/resourcelocator.php
index 9f83673664d..9f83673664d 100644
--- a/lib/template/resourcelocator.php
+++ b/lib/private/template/resourcelocator.php
diff --git a/lib/template/templatefilelocator.php b/lib/private/template/templatefilelocator.php
index d5a484b1a14..d5a484b1a14 100644
--- a/lib/template/templatefilelocator.php
+++ b/lib/private/template/templatefilelocator.php
diff --git a/lib/templatelayout.php b/lib/private/templatelayout.php
index 625f3424a04..625f3424a04 100644
--- a/lib/templatelayout.php
+++ b/lib/private/templatelayout.php
diff --git a/lib/updater.php b/lib/private/updater.php
index df7332a96a9..9827d8a8c12 100644
--- a/lib/updater.php
+++ b/lib/private/updater.php
@@ -56,7 +56,7 @@ class Updater extends BasicEmitter {
$version = \OC_Util::getVersion();
$version['installed'] = \OC_Appconfig::getValue('core', 'installedat');
$version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat');
- $version['updatechannel'] = 'stable';
+ $version['updatechannel'] = \OC_Util::getChannel();
$version['edition'] = \OC_Util::getEditionString();
$versionString = implode('x', $version);
diff --git a/lib/user.php b/lib/private/user.php
index ed75b0bc17c..04cd06b08bd 100644
--- a/lib/user.php
+++ b/lib/private/user.php
@@ -37,54 +37,15 @@
* logout()
*/
class OC_User {
- public static $userSession = null;
-
public static function getUserSession() {
- if (!self::$userSession) {
- $manager = new \OC\User\Manager();
- self::$userSession = new \OC\User\Session($manager, \OC::$session);
- self::$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
- \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
- });
- self::$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
- /** @var $user \OC\User\User */
- \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
- });
- self::$userSession->listen('\OC\User', 'preDelete', function ($user) {
- /** @var $user \OC\User\User */
- \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
- });
- self::$userSession->listen('\OC\User', 'postDelete', function ($user) {
- /** @var $user \OC\User\User */
- \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
- });
- self::$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
- /** @var $user \OC\User\User */
- OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
- });
- self::$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
- /** @var $user \OC\User\User */
- OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
- });
- self::$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
- \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
- });
- self::$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
- /** @var $user \OC\User\User */
- \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
- });
- self::$userSession->listen('\OC\User', 'logout', function () {
- \OC_Hook::emit('OC_User', 'logout', array());
- });
- }
- return self::$userSession;
+ return OC::$server->getUserSession();
}
/**
* @return \OC\User\Manager
*/
public static function getManager() {
- return self::getUserSession()->getManager();
+ return OC::$server->getUserManager();
}
private static $_backends = array();
@@ -253,6 +214,55 @@ class OC_User {
}
/**
+ * @brief Try to login a user, assuming authentication
+ * has already happened (e.g. via Single Sign On).
+ *
+ * Log in a user and regenerate a new session.
+ *
+ * @param \OCP\Authentication\IApacheBackend $backend
+ * @return bool
+ */
+ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backend) {
+
+ $uid = $backend->getCurrentUserId();
+ $run = true;
+ OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid ));
+
+ if($uid) {
+ session_regenerate_id(true);
+ self::setUserId($uid);
+ self::setDisplayName($uid);
+ OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>'' ));
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @brief Verify with Apache whether user is authenticated.
+ *
+ * @return boolean|null
+ * true: authenticated
+ * false: not authenticated
+ * null: not handled / no backend available
+ */
+ public static function handleApacheAuth() {
+ $backend = self::findFirstActiveUsedBackend();
+ if ($backend) {
+ OC_App::loadApps();
+
+ //setup extra user backends
+ self::setupBackends();
+ self::unsetMagicInCookie();
+
+ return self::loginWithApache($backend);
+ }
+
+ return null;
+ }
+
+
+ /**
* @brief Sets user id for session and triggers emit
*/
public static function setUserId($uid) {
@@ -299,6 +309,22 @@ class OC_User {
}
/**
+ * Supplies an attribute to the logout hyperlink. The default behaviour
+ * is to return an href with '?logout=true' appended. However, it can
+ * supply any attribute(s) which are valid for <a>.
+ *
+ * @return string with one or more HTML attributes.
+ */
+ public static function getLogoutAttribute() {
+ $backend = self::findFirstActiveUsedBackend();
+ if ($backend) {
+ return $backend->getLogoutAttribute();
+ }
+
+ return "href=" . link_to('', 'index.php') . "?logout=true";
+ }
+
+ /**
* @brief Check if the user is an admin user
* @param string $uid uid of the admin
* @return bool
@@ -536,4 +562,20 @@ class OC_User {
public static function unsetMagicInCookie() {
self::getUserSession()->unsetMagicInCookie();
}
+
+ /**
+ * @brief Returns the first active backend from self::$_usedBackends.
+ * @return null if no backend active, otherwise OCP\Authentication\IApacheBackend
+ */
+ private static function findFirstActiveUsedBackend() {
+ foreach (self::$_usedBackends as $backend) {
+ if ($backend instanceof OCP\Authentication\IApacheBackend) {
+ if ($backend->isSessionActive()) {
+ return $backend;
+ }
+ }
+ }
+
+ return null;
+ }
}
diff --git a/lib/user/backend.php b/lib/private/user/backend.php
index e9be08e429c..e9be08e429c 100644
--- a/lib/user/backend.php
+++ b/lib/private/user/backend.php
diff --git a/lib/user/database.php b/lib/private/user/database.php
index 9f00a022d9f..9f00a022d9f 100644
--- a/lib/user/database.php
+++ b/lib/private/user/database.php
diff --git a/lib/user/dummy.php b/lib/private/user/dummy.php
index b5b7a6c3c7a..b5b7a6c3c7a 100644
--- a/lib/user/dummy.php
+++ b/lib/private/user/dummy.php
diff --git a/lib/user/example.php b/lib/private/user/example.php
index b2d0dc25410..b2d0dc25410 100644
--- a/lib/user/example.php
+++ b/lib/private/user/example.php
diff --git a/lib/user/http.php b/lib/private/user/http.php
index e99afe59ba7..e99afe59ba7 100644
--- a/lib/user/http.php
+++ b/lib/private/user/http.php
diff --git a/lib/user/interface.php b/lib/private/user/interface.php
index c72bdfaf3fd..c72bdfaf3fd 100644
--- a/lib/user/interface.php
+++ b/lib/private/user/interface.php
diff --git a/lib/user/manager.php b/lib/private/user/manager.php
index 13286bc28a4..13286bc28a4 100644
--- a/lib/user/manager.php
+++ b/lib/private/user/manager.php
diff --git a/lib/user/session.php b/lib/private/user/session.php
index b5e9385234d..525c65ab8a1 100644
--- a/lib/user/session.php
+++ b/lib/private/user/session.php
@@ -27,7 +27,7 @@ use OC\Hooks\Emitter;
*
* @package OC\User
*/
-class Session implements Emitter {
+class Session implements Emitter, \OCP\IUserSession {
/**
* @var \OC\User\Manager $manager
*/
diff --git a/lib/user/user.php b/lib/private/user/user.php
index e5f842944f1..e5f842944f1 100644
--- a/lib/user/user.php
+++ b/lib/private/user/user.php
diff --git a/lib/util.php b/lib/private/util.php
index d4f4eed1ca7..6c0a8d7bab5 100755
--- a/lib/util.php
+++ b/lib/private/util.php
@@ -68,6 +68,7 @@ class OC_Util {
$userDirectory = $userRoot . '/files';
if( !is_dir( $userDirectory )) {
mkdir( $userDirectory, 0755, true );
+ OC_Util::copySkeleton($userDirectory);
}
//jail the user into his "home" directory
\OC\Files\Filesystem::init($user, $userDir);
@@ -93,6 +94,35 @@ class OC_Util {
}
/**
+ * @brief copies the user skeleton files into the fresh user home files
+ * @param string $userDirectory
+ */
+ public static function copySkeleton($userDirectory) {
+ OC_Util::copyr(\OC::$SERVERROOT.'/core/skeleton' , $userDirectory);
+ }
+
+ /**
+ * @brief copies a directory recursively
+ * @param string $source
+ * @param string $target
+ * @return void
+ */
+ public static function copyr($source,$target) {
+ $dir = opendir($source);
+ @mkdir($target);
+ while(false !== ( $file = readdir($dir)) ) {
+ if ( !\OC\Files\Filesystem::isIgnoredDir($file) ) {
+ if ( is_dir($source . '/' . $file) ) {
+ OC_Util::copyr($source . '/' . $file , $target . '/' . $file);
+ } else {
+ copy($source . '/' . $file,$target . '/' . $file);
+ }
+ }
+ }
+ closedir($dir);
+ }
+
+ /**
* @return void
*/
public static function tearDownFS() {
@@ -106,9 +136,8 @@ class OC_Util {
* @return array
*/
public static function getVersion() {
- // hint: We only can count up. Reset minor/patchlevel when
- // updating major/minor version number.
- return array(5, 80, 07);
+ OC_Util::loadVersion();
+ return \OC::$server->getSession()->get('OC_Version');
}
/**
@@ -116,7 +145,8 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '6.0 pre alpha';
+ OC_Util::loadVersion();
+ return \OC::$server->getSession()->get('OC_VersionString');
}
/**
@@ -126,7 +156,49 @@ class OC_Util {
* @return string
*/
public static function getEditionString() {
- return '';
+ OC_Util::loadVersion();
+ return \OC::$server->getSession()->get('OC_Edition');
+ }
+
+ /**
+ * @description get the update channel of the current installed of ownCloud.
+ * @return string
+ */
+ public static function getChannel() {
+ OC_Util::loadVersion();
+ return \OC::$server->getSession()->get('OC_Channel');
+ }
+
+ /**
+ * @description get the build number of the current installed of ownCloud.
+ * @return string
+ */
+ public static function getBuild() {
+ OC_Util::loadVersion();
+ return \OC::$server->getSession()->get('OC_Build');
+ }
+
+ /**
+ * @description load the version.php into the session as cache
+ */
+ private static function loadVersion() {
+ $timestamp = filemtime(OC::$SERVERROOT.'/version.php');
+ if(!\OC::$server->getSession()->exists('OC_Version') or OC::$server->getSession()->get('OC_Version_Timestamp') != $timestamp) {
+ require 'version.php';
+ $session = \OC::$server->getSession();
+ /** @var $timestamp int */
+ $session->set('OC_Version_Timestamp', $timestamp);
+ /** @var $OC_Version string */
+ $session->set('OC_Version', $OC_Version);
+ /** @var $OC_VersionString string */
+ $session->set('OC_VersionString', $OC_VersionString);
+ /** @var $OC_Edition string */
+ $session->set('OC_Edition', $OC_Edition);
+ /** @var $OC_Channel string */
+ $session->set('OC_Channel', $OC_Channel);
+ /** @var $OC_Build string */
+ $session->set('OC_Build', $OC_Build);
+ }
}
/**
@@ -410,14 +482,18 @@ class OC_Util {
$encryptedFiles = false;
if (OC_App::isEnabled('files_encryption') === false) {
$view = new OC\Files\View('/' . OCP\User::getUser());
- if ($view->file_exists('/files_encryption/keyfiles')) {
- $encryptedFiles = true;
+ $keyfilePath = '/files_encryption/keyfiles';
+ if ($view->is_dir($keyfilePath)) {
+ $dircontent = $view->getDirectoryContent($keyfilePath);
+ if (!empty($dircontent)) {
+ $encryptedFiles = true;
+ }
}
}
-
+
return $encryptedFiles;
}
-
+
/**
* @brief Check for correct file permissions of data directory
* @paran string $dataDirectory
@@ -467,6 +543,7 @@ class OC_Util {
}
$parameters['alt_login'] = OC_App::getAlternativeLogIns();
+ $parameters['rememberLoginAllowed'] = self::rememberLoginAllowed();
OC_Template::printGuestPage("", "login", $parameters);
}
@@ -509,6 +586,27 @@ class OC_Util {
}
/**
+ * Check if it is allowed to remember login.
+ *
+ * @note Every app can set 'rememberlogin' to 'false' to disable the remember login feature
+ *
+ * @return bool
+ */
+ public static function rememberLoginAllowed() {
+
+ $apps = OC_App::getEnabledApps();
+
+ foreach ($apps as $app) {
+ $appInfo = OC_App::getAppInfo($app);
+ if (isset($appInfo['rememberlogin']) && $appInfo['rememberlogin'] === 'false') {
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+ /**
* @brief Check if the user is a subadmin, redirects to home if not
* @return array $groups where the current user is subadmin
*/
@@ -552,7 +650,7 @@ class OC_Util {
if(is_null($id)) {
// We need to guarantee at least one letter in instanceid so it can be used as the session_name
$id = 'oc' . self::generateRandomBytes(10);
- OC_Config::setValue('instanceid', $id);
+ OC_Config::$object->setValue('instanceid', $id);
}
return $id;
}
@@ -600,29 +698,7 @@ class OC_Util {
* @see OC_Util::callRegister()
*/
public static function isCallRegistered() {
- if(!\OC::$session->exists('requesttoken')) {
- return false;
- }
-
- if(isset($_GET['requesttoken'])) {
- $token = $_GET['requesttoken'];
- } elseif(isset($_POST['requesttoken'])) {
- $token = $_POST['requesttoken'];
- } elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) {
- $token = $_SERVER['HTTP_REQUESTTOKEN'];
- } else {
- //no token found.
- return false;
- }
-
- // Check if the token is valid
- if($token !== \OC::$session->get('requesttoken')) {
- // Not valid
- return false;
- } else {
- // Valid token
- return true;
- }
+ return \OC::$server->getRequest()->passesCSRFCheck();
}
/**
@@ -654,16 +730,16 @@ class OC_Util {
}
return $value;
}
-
+
/**
* @brief Public function to encode url parameters
*
* This function is used to encode path to file before output.
* Encoding is done according to RFC 3986 with one exception:
- * Character '/' is preserved as is.
+ * Character '/' is preserved as is.
*
* @param string $component part of URI to encode
- * @return string
+ * @return string
*/
public static function encodePath($component) {
$encoded = rawurlencode($component);
@@ -801,7 +877,7 @@ class OC_Util {
}
}
}
-
+
/**
* @brief Check if the connection to the internet is disabled on purpose
* @return bool
@@ -887,9 +963,9 @@ class OC_Util {
* @param string $url Url to get content
* @return string of the response or false on error
* This function get the content of a page via curl, if curl is enabled.
- * If not, file_get_element is used.
+ * If not, file_get_contents is used.
*/
- public static function getUrlContent($url){
+ public static function getUrlContent($url) {
if (function_exists('curl_init')) {
$curl = curl_init();
diff --git a/lib/vobject.php b/lib/private/vobject.php
index 267176ebc07..267176ebc07 100644
--- a/lib/vobject.php
+++ b/lib/private/vobject.php
diff --git a/lib/vobject/compoundproperty.php b/lib/private/vobject/compoundproperty.php
index 7fe42574bed..7fe42574bed 100644
--- a/lib/vobject/compoundproperty.php
+++ b/lib/private/vobject/compoundproperty.php
diff --git a/lib/vobject/stringproperty.php b/lib/private/vobject/stringproperty.php
index a9d63a0a789..a9d63a0a789 100644
--- a/lib/vobject/stringproperty.php
+++ b/lib/private/vobject/stringproperty.php
diff --git a/lib/public/app.php b/lib/public/app.php
index a1ecf524cc8..0a5721b334e 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -35,10 +35,10 @@ namespace OCP;
*/
class App {
/**
- * @brief Makes owncloud aware of this 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
+ * @returns boolean
*
* @deprecated this method is deprecated
* Do not call it anymore
@@ -52,7 +52,7 @@ class App {
/**
* @brief adds an entry to the navigation
* @param $data array containing the data
- * @returns true/false
+ * @returns boolean
*
* This function adds a new entry to the navigation visible to users. $data
* is an associative array.
@@ -72,8 +72,8 @@ class App {
/**
* @brief marks a navigation entry as active
- * @param $id id of the entry
- * @returns true/false
+ * @param $id string id of the entry
+ * @returns boolean
*
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
@@ -104,7 +104,7 @@ class App {
/**
* @brief Read app metadata from the info.xml file
* @param string $app id of the app or the path of the info.xml file
- * @param boolean path (optional)
+ * @param boolean $path (optional)
* @returns array
*/
public static function getAppInfo( $app, $path=false ) {
@@ -114,7 +114,7 @@ class App {
/**
* @brief checks whether or not an app is enabled
* @param $app app
- * @returns true/false
+ * @returns boolean
*
* This function checks whether or not an app is enabled.
*/
@@ -133,7 +133,7 @@ class App {
/**
* @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
* @param $app app
- * @returns true/false
+ * @returns boolean
*/
public static function getAppVersion( $app ) {
return \OC_App::getAppVersion( $app );
diff --git a/lib/public/appframework/app.php b/lib/public/appframework/app.php
new file mode 100644
index 00000000000..d97c5c81848
--- /dev/null
+++ b/lib/public/appframework/app.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\AppFramework;
+
+
+/**
+ * Class App
+ * @package OCP\AppFramework
+ *
+ * Any application must inherit this call - all controller instances to be used are
+ * to be registered using IContainer::registerService
+ */
+class App {
+ public function __construct($appName) {
+ $this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName);
+ }
+
+ private $container;
+
+ /**
+ * @return IAppContainer
+ */
+ public function getContainer() {
+ return $this->container;
+ }
+
+ /**
+ * This function is called by the routing component to fire up the frameworks dispatch mechanism.
+ *
+ * Example code in routes.php of the task app:
+ * $this->create('tasks_index', '/')->get()->action(
+ * function($params){
+ * $app = new TaskApp();
+ * $app->dispatch('PageController', 'index', $params);
+ * }
+ * );
+ *
+ *
+ * Example for for TaskApp implementation:
+ * class TaskApp extends \OCP\AppFramework\App {
+ *
+ * public function __construct(){
+ * parent::__construct('tasks');
+ *
+ * $this->getContainer()->registerService('PageController', function(IAppContainer $c){
+ * $a = $c->query('API');
+ * $r = $c->query('Request');
+ * return new PageController($a, $r);
+ * });
+ * }
+ * }
+ *
+ * @param string $controllerName the name of the controller under which it is
+ * stored in the DI container
+ * @param string $methodName the method that you want to call
+ * @param array $urlParams an array with variables extracted from the routes
+ */
+ public function dispatch($controllerName, $methodName, array $urlParams) {
+ \OC\AppFramework\App::main($controllerName, $methodName, $urlParams, $this->container);
+ }
+}
diff --git a/lib/public/appframework/http/http.php b/lib/public/appframework/http/http.php
new file mode 100644
index 00000000000..9eafe782726
--- /dev/null
+++ b/lib/public/appframework/http/http.php
@@ -0,0 +1,89 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt, Thomas Tanghus, Bart Visscher
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework\Http;
+
+
+class Http {
+
+ const STATUS_CONTINUE = 100;
+ const STATUS_SWITCHING_PROTOCOLS = 101;
+ const STATUS_PROCESSING = 102;
+ const STATUS_OK = 200;
+ const STATUS_CREATED = 201;
+ const STATUS_ACCEPTED = 202;
+ const STATUS_NON_AUTHORATIVE_INFORMATION = 203;
+ const STATUS_NO_CONTENT = 204;
+ const STATUS_RESET_CONTENT = 205;
+ const STATUS_PARTIAL_CONTENT = 206;
+ const STATUS_MULTI_STATUS = 207;
+ const STATUS_ALREADY_REPORTED = 208;
+ const STATUS_IM_USED = 226;
+ const STATUS_MULTIPLE_CHOICES = 300;
+ const STATUS_MOVED_PERMANENTLY = 301;
+ const STATUS_FOUND = 302;
+ const STATUS_SEE_OTHER = 303;
+ const STATUS_NOT_MODIFIED = 304;
+ const STATUS_USE_PROXY = 305;
+ const STATUS_RESERVED = 306;
+ const STATUS_TEMPORARY_REDIRECT = 307;
+ const STATUS_BAD_REQUEST = 400;
+ const STATUS_UNAUTHORIZED = 401;
+ const STATUS_PAYMENT_REQUIRED = 402;
+ const STATUS_FORBIDDEN = 403;
+ const STATUS_NOT_FOUND = 404;
+ const STATUS_METHOD_NOT_ALLOWED = 405;
+ const STATUS_NOT_ACCEPTABLE = 406;
+ const STATUS_PROXY_AUTHENTICATION_REQUIRED = 407;
+ const STATUS_REQUEST_TIMEOUT = 408;
+ const STATUS_CONFLICT = 409;
+ const STATUS_GONE = 410;
+ const STATUS_LENGTH_REQUIRED = 411;
+ const STATUS_PRECONDITION_FAILED = 412;
+ const STATUS_REQUEST_ENTITY_TOO_LARGE = 413;
+ const STATUS_REQUEST_URI_TOO_LONG = 414;
+ const STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
+ const STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416;
+ const STATUS_EXPECTATION_FAILED = 417;
+ const STATUS_IM_A_TEAPOT = 418;
+ const STATUS_UNPROCESSABLE_ENTITY = 422;
+ const STATUS_LOCKED = 423;
+ const STATUS_FAILED_DEPENDENCY = 424;
+ const STATUS_UPGRADE_REQUIRED = 426;
+ const STATUS_PRECONDITION_REQUIRED = 428;
+ const STATUS_TOO_MANY_REQUESTS = 429;
+ const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
+ const STATUS_INTERNAL_SERVER_ERROR = 500;
+ const STATUS_NOT_IMPLEMENTED = 501;
+ const STATUS_BAD_GATEWAY = 502;
+ const STATUS_SERVICE_UNAVAILABLE = 503;
+ const STATUS_GATEWAY_TIMEOUT = 504;
+ const STATUS_HTTP_VERSION_NOT_SUPPORTED = 505;
+ const STATUS_VARIANT_ALSO_NEGOTIATES = 506;
+ const STATUS_INSUFFICIENT_STORAGE = 507;
+ const STATUS_LOOP_DETECTED = 508;
+ const STATUS_BANDWIDTH_LIMIT_EXCEEDED = 509;
+ const STATUS_NOT_EXTENDED = 510;
+ const STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511;
+}
diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php
new file mode 100644
index 00000000000..085fdbed2f9
--- /dev/null
+++ b/lib/public/appframework/http/jsonresponse.php
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework\Http;
+
+
+/**
+ * A renderer for JSON calls
+ */
+class JSONResponse extends Response {
+
+ protected $data;
+
+
+ /**
+ * @param array|object $data the object or array that should be transformed
+ * @param int $statusCode the Http status code, defaults to 200
+ */
+ public function __construct($data=array(), $statusCode=Http::STATUS_OK) {
+ $this->data = $data;
+ $this->setStatus($statusCode);
+ $this->addHeader('X-Content-Type-Options', 'nosniff');
+ $this->addHeader('Content-type', 'application/json; charset=utf-8');
+ }
+
+
+ /**
+ * Returns the rendered json
+ * @return string the rendered json
+ */
+ public function render(){
+ return json_encode($this->data);
+ }
+
+ /**
+ * Sets values in the data json array
+ * @param array|object $params an array or object which will be transformed
+ * to JSON
+ */
+ public function setData($data){
+ $this->data = $data;
+ }
+
+
+ /**
+ * Used to get the set parameters
+ * @return array the data
+ */
+ public function getData(){
+ return $this->data;
+ }
+
+}
diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php
new file mode 100644
index 00000000000..64477258948
--- /dev/null
+++ b/lib/public/appframework/http/response.php
@@ -0,0 +1,169 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt, Thomas Tanghus, Bart Visscher
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework\Http;
+
+
+/**
+ * Base class for responses. Also used to just send headers
+ */
+class Response {
+
+ /**
+ * @var array default headers
+ */
+ private $headers = array(
+ 'Cache-Control' => 'no-cache, must-revalidate'
+ );
+
+
+ /**
+ * @var string
+ */
+ private $status = Http::STATUS_OK;
+
+
+ /**
+ * @var \DateTime
+ */
+ private $lastModified;
+
+
+ /**
+ * @var string
+ */
+ private $ETag;
+
+
+ /**
+ * Caches the response
+ * @param int $cacheSeconds the amount of seconds that should be cached
+ * if 0 then caching will be disabled
+ */
+ public function cacheFor($cacheSeconds) {
+
+ if($cacheSeconds > 0) {
+ $this->addHeader('Cache-Control', 'max-age=' . $cacheSeconds .
+ ', must-revalidate');
+ } else {
+ $this->addHeader('Cache-Control', 'no-cache, must-revalidate');
+ }
+
+ }
+
+
+ /**
+ * Adds a new header to the response that will be called before the render
+ * function
+ * @param string $name The name of the HTTP header
+ * @param string $value The value, null will delete it
+ */
+ public function addHeader($name, $value) {
+ if(is_null($value)) {
+ unset($this->headers[$name]);
+ } else {
+ $this->headers[$name] = $value;
+ }
+ }
+
+
+ /**
+ * Returns the set headers
+ * @return array the headers
+ */
+ public function getHeaders() {
+ $mergeWith = array();
+
+ if($this->lastModified) {
+ $mergeWith['Last-Modified'] =
+ $this->lastModified->format(\DateTime::RFC2822);
+ }
+
+ if($this->ETag) {
+ $mergeWith['ETag'] = '"' . $this->ETag . '"';
+ }
+
+ return array_merge($mergeWith, $this->headers);
+ }
+
+
+ /**
+ * By default renders no output
+ * @return null
+ */
+ public function render() {
+ return null;
+ }
+
+
+ /**
+ * Set response status
+ * @param int $status a HTTP status code, see also the STATUS constants
+ */
+ public function setStatus($status) {
+ $this->status = $status;
+ }
+
+
+ /**
+ * Get response status
+ */
+ public function getStatus() {
+ return $this->status;
+ }
+
+
+ /**
+ * @return string the etag
+ */
+ public function getETag() {
+ return $this->ETag;
+ }
+
+
+ /**
+ * @return string RFC2822 formatted last modified date
+ */
+ public function getLastModified() {
+ return $this->lastModified;
+ }
+
+
+ /**
+ * @param string $ETag
+ */
+ public function setETag($ETag) {
+ $this->ETag = $ETag;
+ }
+
+
+ /**
+ * @param \DateTime $lastModified
+ */
+ public function setLastModified($lastModified) {
+ $this->lastModified = $lastModified;
+ }
+
+
+}
diff --git a/lib/public/appframework/http/templateresponse.php b/lib/public/appframework/http/templateresponse.php
new file mode 100644
index 00000000000..97678c96cba
--- /dev/null
+++ b/lib/public/appframework/http/templateresponse.php
@@ -0,0 +1,126 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework\Http;
+
+use OC\AppFramework\Core\API;
+
+
+/**
+ * Response for a normal template
+ */
+class TemplateResponse extends Response {
+
+ protected $templateName;
+ protected $params;
+ protected $api;
+ protected $renderAs;
+ protected $appName;
+
+ /**
+ * @param API $api an API instance
+ * @param string $templateName the name of the template
+ * @param string $appName optional if you want to include a template from
+ * a different app
+ */
+ public function __construct(API $api, $templateName, $appName=null) {
+ $this->templateName = $templateName;
+ $this->appName = $appName;
+ $this->api = $api;
+ $this->params = array();
+ $this->renderAs = 'user';
+ }
+
+
+ /**
+ * Sets template parameters
+ * @param array $params an array with key => value structure which sets template
+ * variables
+ */
+ public function setParams(array $params){
+ $this->params = $params;
+ }
+
+
+ /**
+ * Used for accessing the set parameters
+ * @return array the params
+ */
+ public function getParams(){
+ return $this->params;
+ }
+
+
+ /**
+ * Used for accessing the name of the set template
+ * @return string the name of the used template
+ */
+ public function getTemplateName(){
+ return $this->templateName;
+ }
+
+
+ /**
+ * Sets the template page
+ * @param string $renderAs admin, user or blank. Admin also prints the admin
+ * settings header and footer, user renders the normal
+ * normal page including footer and header and blank
+ * just renders the plain template
+ */
+ public function renderAs($renderAs){
+ $this->renderAs = $renderAs;
+ }
+
+
+ /**
+ * Returns the set renderAs
+ * @return string the renderAs value
+ */
+ public function getRenderAs(){
+ return $this->renderAs;
+ }
+
+
+ /**
+ * Returns the rendered html
+ * @return string the rendered html
+ */
+ public function render(){
+
+ if($this->appName !== null){
+ $appName = $this->appName;
+ } else {
+ $appName = $this->api->getAppName();
+ }
+
+ $template = $this->api->getTemplate($this->templateName, $this->renderAs, $appName);
+
+ foreach($this->params as $key => $value){
+ $template->assign($key, $value);
+ }
+
+ return $template->fetchPage();
+ }
+
+}
diff --git a/lib/public/appframework/iapi.php b/lib/public/appframework/iapi.php
new file mode 100644
index 00000000000..fa6af5f5965
--- /dev/null
+++ b/lib/public/appframework/iapi.php
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework;
+
+
+/**
+ * A few very basic and frequently used API functions are combined in here
+ */
+interface IApi {
+
+
+ /**
+ * Gets the userid of the current user
+ * @return string the user id of the current user
+ */
+ function getUserId();
+
+
+ /**
+ * Adds a new javascript file
+ * @param string $scriptName the name of the javascript in js/ without the suffix
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ function addScript($scriptName, $appName = null);
+
+
+ /**
+ * Adds a new css file
+ * @param string $styleName the name of the css file in css/without the suffix
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ function addStyle($styleName, $appName = null);
+
+
+ /**
+ * shorthand for addScript for files in the 3rdparty directory
+ * @param string $name the name of the file without the suffix
+ */
+ function add3rdPartyScript($name);
+
+
+ /**
+ * shorthand for addStyle for files in the 3rdparty directory
+ * @param string $name the name of the file without the suffix
+ */
+ function add3rdPartyStyle($name);
+
+ /**
+ * Returns the translation object
+ * @return \OC_L10N the translation object
+ *
+ * FIXME: returns private object / should be retrieved from teh ServerContainer
+ */
+ function getTrans();
+
+
+ /**
+ * Returns the URL for a route
+ * @param string $routeName the name of the route
+ * @param array $arguments an array with arguments which will be filled into the url
+ * @return string the url
+ */
+ function linkToRoute($routeName, $arguments=array());
+
+
+ /**
+ * Returns an URL for an image or file
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ function linkTo($file, $appName=null);
+
+
+ /**
+ * Returns the link to an image, like link to but only with prepending img/
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ */
+ function imagePath($file, $appName = null);
+
+
+ /**
+ * Makes an URL absolute
+ * @param string $url the url
+ * @return string the absolute url
+ *
+ * FIXME: function should live in Request / Response
+ */
+ function getAbsoluteURL($url);
+
+
+ /**
+ * links to a file
+ * @param string $file the name of the file
+ * @param string $appName the name of the app, defaults to the current one
+ * @deprecated replaced with linkToRoute()
+ * @return string the url
+ */
+ function linkToAbsolute($file, $appName = null);
+
+
+ /**
+ * Checks if an app is enabled
+ * @param string $appName the name of an app
+ * @return bool true if app is enabled
+ */
+ public function isAppEnabled($appName);
+
+
+ /**
+ * Writes a function into the error log
+ * @param string $msg the error message to be logged
+ * @param int $level the error level
+ *
+ * FIXME: add logger instance to ServerContainer
+ */
+ function log($msg, $level = null);
+
+
+ /**
+ * Returns a template
+ * @param string $templateName the name of the template
+ * @param string $renderAs how it should be rendered
+ * @param string $appName the name of the app
+ * @return \OCP\Template a new template
+ */
+ function getTemplate($templateName, $renderAs='user', $appName=null);
+
+}
diff --git a/lib/public/appframework/iappcontainer.php b/lib/public/appframework/iappcontainer.php
new file mode 100644
index 00000000000..7d3b4b3bac7
--- /dev/null
+++ b/lib/public/appframework/iappcontainer.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\AppFramework;
+
+use OCP\AppFramework\IApi;
+use OCP\IContainer;
+
+/**
+ * Class IAppContainer
+ * @package OCP\AppFramework
+ *
+ * This container interface provides short cuts for app developers to access predefined app service.
+ */
+interface IAppContainer extends IContainer{
+
+ /**
+ * used to return the appname of the set application
+ * @return string the name of your application
+ */
+ function getAppName();
+
+ /**
+ * @return IApi
+ */
+ function getCoreApi();
+
+ /**
+ * @return \OCP\IServerContainer
+ */
+ function getServer();
+
+ /**
+ * @param IMiddleWare $middleWare
+ * @return boolean
+ */
+ function registerMiddleWare(IMiddleWare $middleWare);
+}
diff --git a/lib/public/appframework/middleware.php b/lib/public/appframework/middleware.php
new file mode 100644
index 00000000000..12776c119c0
--- /dev/null
+++ b/lib/public/appframework/middleware.php
@@ -0,0 +1,100 @@
+<?php
+
+/**
+ * ownCloud - App Framework
+ *
+ * @author Bernhard Posselt
+ * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCP\AppFramework;
+
+use OCP\AppFramework\Http\Response;
+
+
+/**
+ * Middleware is used to provide hooks before or after controller methods and
+ * deal with possible exceptions raised in the controller methods.
+ * They're modeled after Django's middleware system:
+ * https://docs.djangoproject.com/en/dev/topics/http/middleware/
+ */
+abstract class Middleware {
+
+
+ /**
+ * This is being run in normal order before the controller is being
+ * called which allows several modifications and checks
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ */
+ public function beforeController($controller, $methodName){
+
+ }
+
+
+ /**
+ * This is being run when either the beforeController method or the
+ * controller method itself is throwing an exception. The middleware is
+ * asked in reverse order to handle the exception and to return a response.
+ * If the response is null, it is assumed that the exception could not be
+ * handled and the error will be thrown again
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param \Exception $exception the thrown exception
+ * @throws \Exception the passed in exception if it cant handle it
+ * @return Response a Response object in case that the exception was handled
+ */
+ public function afterException($controller, $methodName, \Exception $exception){
+ throw $exception;
+ }
+
+
+ /**
+ * This is being run after a successful controllermethod call and allows
+ * the manipulation of a Response object. The middleware is run in reverse order
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param Response $response the generated response from the controller
+ * @return Response a Response object
+ */
+ public function afterController($controller, $methodName, Response $response){
+ return $response;
+ }
+
+
+ /**
+ * This is being run after the response object has been rendered and
+ * allows the manipulation of the output. The middleware is run in reverse order
+ *
+ * @param Controller $controller the controller that is being called
+ * @param string $methodName the name of the method that will be called on
+ * the controller
+ * @param string $output the generated output from a response
+ * @return string the output that should be printed
+ */
+ public function beforeOutput($controller, $methodName, $output){
+ return $output;
+ }
+
+}
diff --git a/lib/public/authentication/iapachebackend.php b/lib/public/authentication/iapachebackend.php
new file mode 100644
index 00000000000..5376baf525c
--- /dev/null
+++ b/lib/public/authentication/iapachebackend.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * ownCloud - Apache backend
+ *
+ * @author Karl Beecher
+ * @copyright 2013 Karl Beecher - karl@endocode.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Authentication;
+
+interface IApacheBackend {
+
+ /**
+ * In case the user has been authenticated by Apache true is returned.
+ *
+ * @return boolean whether Apache reports a user as currently logged in.
+ */
+ public function isSessionActive();
+
+ /**
+ * Creates an attribute which is added to the logout hyperlink. It can
+ * supply any attribute(s) which are valid for <a>.
+ *
+ * @return string with one or more HTML attributes.
+ */
+ public function getLogoutAttribute();
+
+ /**
+ * Return the id of the current user
+ * @return string
+ */
+ public function getCurrentUserId();
+
+}
diff --git a/lib/public/contacts.php b/lib/public/contacts.php
index 88d812e735a..1b61d7aa4ff 100644
--- a/lib/public/contacts.php
+++ b/lib/public/contacts.php
@@ -90,13 +90,8 @@ namespace OCP {
* @return array of contacts which are arrays of key-value-pairs
*/
public static function search($pattern, $searchProperties = array(), $options = array()) {
- $result = array();
- foreach(self::$address_books as $address_book) {
- $r = $address_book->search($pattern, $searchProperties, $options);
- $result = array_merge($result, $r);
- }
-
- return $result;
+ $cm = \OC::$server->getContactsManager();
+ return $cm->search($pattern, $searchProperties, $options);
}
/**
@@ -107,14 +102,8 @@ namespace OCP {
* @return bool successful or not
*/
public static function delete($id, $address_book_key) {
- if (!array_key_exists($address_book_key, self::$address_books))
- return null;
-
- $address_book = self::$address_books[$address_book_key];
- if ($address_book->getPermissions() & \OCP\PERMISSION_DELETE)
- return null;
-
- return $address_book->delete($id);
+ $cm = \OC::$server->getContactsManager();
+ return $cm->delete($id, $address_book_key);
}
/**
@@ -126,15 +115,8 @@ namespace OCP {
* @return array representing the contact just created or updated
*/
public static function createOrUpdate($properties, $address_book_key) {
-
- if (!array_key_exists($address_book_key, self::$address_books))
- return null;
-
- $address_book = self::$address_books[$address_book_key];
- if ($address_book->getPermissions() & \OCP\PERMISSION_CREATE)
- return null;
-
- return $address_book->createOrUpdate($properties);
+ $cm = \OC::$server->getContactsManager();
+ return $cm->search($properties, $address_book_key);
}
/**
@@ -143,45 +125,40 @@ namespace OCP {
* @return bool true if enabled, false if not
*/
public static function isEnabled() {
- return !empty(self::$address_books);
+ $cm = \OC::$server->getContactsManager();
+ return $cm->isEnabled();
}
/**
* @param \OCP\IAddressBook $address_book
*/
public static function registerAddressBook(\OCP\IAddressBook $address_book) {
- self::$address_books[$address_book->getKey()] = $address_book;
+ $cm = \OC::$server->getContactsManager();
+ return $cm->registerAddressBook($address_book);
}
/**
* @param \OCP\IAddressBook $address_book
*/
public static function unregisterAddressBook(\OCP\IAddressBook $address_book) {
- unset(self::$address_books[$address_book->getKey()]);
+ $cm = \OC::$server->getContactsManager();
+ return $cm->unregisterAddressBook($address_book);
}
/**
* @return array
*/
public static function getAddressBooks() {
- $result = array();
- foreach(self::$address_books as $address_book) {
- $result[$address_book->getKey()] = $address_book->getDisplayName();
- }
-
- return $result;
+ $cm = \OC::$server->getContactsManager();
+ return $cm->getAddressBooks();
}
/**
* removes all registered address book instances
*/
public static function clear() {
- self::$address_books = array();
+ $cm = \OC::$server->getContactsManager();
+ $cm->clear();
}
-
- /**
- * @var \OCP\IAddressBook[] which holds all registered address books
- */
- private static $address_books = array();
}
}
diff --git a/lib/public/contacts/imanager.php b/lib/public/contacts/imanager.php
new file mode 100644
index 00000000000..3bfbca7be50
--- /dev/null
+++ b/lib/public/contacts/imanager.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Contacts Class
+ *
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP\Contacts {
+
+ /**
+ * This class provides access to the contacts app. Use this class exclusively if you want to access contacts.
+ *
+ * Contacts in general will be expressed as an array of key-value-pairs.
+ * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1
+ *
+ * Proposed workflow for working with contacts:
+ * - search for the contacts
+ * - manipulate the results array
+ * - createOrUpdate will save the given contacts overwriting the existing data
+ *
+ * For updating it is mandatory to keep the id.
+ * Without an id a new contact will be created.
+ *
+ */
+ interface IManager {
+
+ /**
+ * This function is used to search and find contacts within the users address books.
+ * In case $pattern is empty all contacts will be returned.
+ *
+ * Example:
+ * Following function shows how to search for contacts for the name and the email address.
+ *
+ * public static function getMatchingRecipient($term) {
+ * $cm = \OC::$server->getContactsManager();
+ * // The API is not active -> nothing to do
+ * if (!$cm->isEnabled()) {
+ * return array();
+ * }
+ *
+ * $result = $cm->search($term, array('FN', 'EMAIL'));
+ * $receivers = array();
+ * foreach ($result as $r) {
+ * $id = $r['id'];
+ * $fn = $r['FN'];
+ * $email = $r['EMAIL'];
+ * if (!is_array($email)) {
+ * $email = array($email);
+ * }
+ *
+ * // loop through all email addresses of this contact
+ * foreach ($email as $e) {
+ * $displayName = $fn . " <$e>";
+ * $receivers[] = array(
+ * 'id' => $id,
+ * 'label' => $displayName,
+ * 'value' => $displayName);
+ * }
+ * }
+ *
+ * return $receivers;
+ * }
+ *
+ *
+ * @param string $pattern which should match within the $searchProperties
+ * @param array $searchProperties defines the properties within the query pattern should match
+ * @param array $options - for future use. One should always have options!
+ * @return array of contacts which are arrays of key-value-pairs
+ */
+ function search($pattern, $searchProperties = array(), $options = array());
+
+ /**
+ * This function can be used to delete the contact identified by the given id
+ *
+ * @param object $id the unique identifier to a contact
+ * @param $address_book_key
+ * @return bool successful or not
+ */
+ function delete($id, $address_book_key);
+
+ /**
+ * This function is used to create a new contact if 'id' is not given or not present.
+ * Otherwise the contact will be updated by replacing the entire data set.
+ *
+ * @param array $properties this array if key-value-pairs defines a contact
+ * @param $address_book_key string to identify the address book in which the contact shall be created or updated
+ * @return array representing the contact just created or updated
+ */
+ function createOrUpdate($properties, $address_book_key);
+
+ /**
+ * Check if contacts are available (e.g. contacts app enabled)
+ *
+ * @return bool true if enabled, false if not
+ */
+ function isEnabled();
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ function registerAddressBook(\OCP\IAddressBook $address_book);
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ function unregisterAddressBook(\OCP\IAddressBook $address_book);
+
+ /**
+ * In order to improve lazy loading a closure can be registered which will be called in case
+ * address books are actually requested
+ *
+ * @param string $key
+ * @param \Closure $callable
+ */
+ function register($key, \Closure $callable);
+
+ /**
+ * @return array
+ */
+ function getAddressBooks();
+
+ /**
+ * removes all registered address book instances
+ */
+ function clear();
+ }
+}
diff --git a/lib/public/icache.php b/lib/public/icache.php
new file mode 100644
index 00000000000..436ee71b2b9
--- /dev/null
+++ b/lib/public/icache.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+namespace OCP;
+
+/**
+ * This interface defines method for accessing the file based user cache.
+ */
+interface ICache {
+
+ /**
+ * Get a value from the user cache
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function get($key);
+
+ /**
+ * Set a value in the user cache
+ *
+ * @param string $key
+ * @param mixed $value
+ * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
+ * @return bool
+ */
+ public function set($key, $value, $ttl = 0);
+
+ /**
+ * Check if a value is set in the user cache
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function hasKey($key);
+
+ /**
+ * Remove an item from the user cache
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function remove($key);
+
+ /**
+ * clear the user cache of all entries starting with a prefix
+ * @param string $prefix (optional)
+ * @return bool
+ */
+ public function clear($prefix = '');
+}
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
new file mode 100644
index 00000000000..850bddf6935
--- /dev/null
+++ b/lib/public/iconfig.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Access to all the configuration options ownCloud offers
+ */
+interface IConfig {
+ /**
+ * Sets a new system wide value
+ * @param string $key the key of the value, under which will be saved
+ * @param string $value the value that should be stored
+ * @todo need a use case for this
+ */
+// public function setSystemValue($key, $value);
+
+ /**
+ * Looks up a system wide defined value
+ * @param string $key the key of the value, under which it was saved
+ * @return string the saved value
+ */
+ public function getSystemValue($key);
+
+
+ /**
+ * Writes a new app wide value
+ * @param string $appName the appName that we want to store the value under
+ * @param string $key the key of the value, under which will be saved
+ * @param string $value the value that should be stored
+ */
+ public function setAppValue($appName, $key, $value);
+
+ /**
+ * Looks up an app wide defined value
+ * @param string $appName the appName that we stored the value under
+ * @param string $key the key of the value, under which it was saved
+ * @return string the saved value
+ */
+ public function getAppValue($appName, $key);
+
+
+ /**
+ * Set a user defined value
+ * @param string $userId the userId of the user that we want to store the value under
+ * @param string $appName the appName that we want to store the value under
+ * @param string $key the key under which the value is being stored
+ * @param string $value the value that you want to store
+ */
+ public function setUserValue($userId, $appName, $key, $value);
+
+ /**
+ * Shortcut for getting a user defined value
+ * @param string $userId the userId of the user that we want to store the value under
+ * @param string $appName the appName that we stored the value under
+ * @param string $key the key under which the value is being stored
+ */
+ public function getUserValue($userId, $appName, $key);
+}
diff --git a/lib/public/icontainer.php b/lib/public/icontainer.php
new file mode 100644
index 00000000000..d43c1c90f11
--- /dev/null
+++ b/lib/public/icontainer.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Class IContainer
+ *
+ * IContainer is the basic interface to be used for any internal dependency injection mechanism
+ *
+ * @package OCP
+ */
+interface IContainer {
+
+ /**
+ * Look up a service for a given name in the container.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ function query($name);
+
+ /**
+ * A value is stored in the container with it's corresponding name
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ */
+ function registerParameter($name, $value);
+
+ /**
+ * A service is registered in the container where a closure is passed in which will actually
+ * create the service on demand.
+ * In case the parameter $shared is set to true (the default usage) the once created service will remain in
+ * memory and be reused on subsequent calls.
+ * In case the parameter is false the service will be recreated on every call.
+ *
+ * @param string $name
+ * @param callable $closure
+ * @param bool $shared
+ * @return void
+ */
+ function registerService($name, \Closure $closure, $shared = true);
+}
diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php
new file mode 100644
index 00000000000..c741a0f061a
--- /dev/null
+++ b/lib/public/idbconnection.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * TODO: Description
+ */
+interface IDBConnection {
+ /**
+ * Used to abstract the owncloud database access away
+ * @param string $sql the sql query with ? placeholder for params
+ * @param int $limit the maximum number of rows
+ * @param int $offset from which row we want to start
+ * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
+ */
+ public function prepare($sql, $limit=null, $offset=null);
+
+ /**
+ * Used to get the id of the just inserted element
+ * @param string $tableName the name of the table where we inserted the item
+ * @return int the id of the inserted element
+ */
+ public function lastInsertId($table = null);
+
+ /**
+ * @brief Insert a row if a matching row doesn't exists.
+ * @param $table string The table name (will replace *PREFIX*) to perform the replace on.
+ * @param $input array
+ *
+ * The input array if in the form:
+ *
+ * array ( 'id' => array ( 'value' => 6,
+ * 'key' => true
+ * ),
+ * 'name' => array ('value' => 'Stoyan'),
+ * 'family' => array ('value' => 'Stefanov'),
+ * 'birth_date' => array ('value' => '1975-06-20')
+ * );
+ * @return bool
+ *
+ */
+ public function insertIfNotExist($table, $input);
+
+ /**
+ * @brief Start a transaction
+ * @return bool TRUE on success or FALSE on failure
+ */
+ public function beginTransaction();
+
+ /**
+ * @brief Commit the database changes done during a transaction that is in progress
+ * @return bool TRUE on success or FALSE on failure
+ */
+ public function commit();
+
+ /**
+ * @brief Rollback the database changes done during a transaction that is in progress
+ * @return bool TRUE on success or FALSE on failure
+ */
+ public function rollBack();
+
+ /**
+ * returns the error code and message as a string for logging
+ * @return string
+ */
+ public function getError();
+}
diff --git a/lib/public/ihelper.php b/lib/public/ihelper.php
new file mode 100644
index 00000000000..fad02f7556a
--- /dev/null
+++ b/lib/public/ihelper.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Functions that don't have any specific interface to place
+ */
+interface IHelper {
+ /**
+ * Gets the content of an URL by using CURL or a fallback if it is not
+ * installed
+ * @param string $url the url that should be fetched
+ * @return string the content of the webpage
+ */
+ public function getUrlContent($url);
+}
diff --git a/lib/public/il10n.php b/lib/public/il10n.php
new file mode 100644
index 00000000000..9cf9093d391
--- /dev/null
+++ b/lib/public/il10n.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * TODO: Description
+ */
+interface IL10N {
+ /**
+ * @brief Translating
+ * @param $text String The text we need a translation for
+ * @param array $parameters default:array() Parameters for sprintf
+ * @return \OC_L10N_String|string Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $text will be
+ * returned.
+ */
+ public function t($text, $parameters = array());
+
+ /**
+ * @brief Translating
+ * @param $text_singular String the string to translate for exactly one object
+ * @param $text_plural String the string to translate for n objects
+ * @param $count Integer Number of objects
+ * @param array $parameters default:array() Parameters for sprintf
+ * @return \OC_L10N_String|string Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $text will be
+ * returned. %n will be replaced with the number of objects.
+ *
+ * The correct plural is determined by the plural_forms-function
+ * provided by the po file.
+ *
+ */
+ public function n($text_singular, $text_plural, $count, $parameters = array());
+
+ /**
+ * @brief Localization
+ * @param $type Type of localization
+ * @param $params parameters for this localization
+ * @returns String or false
+ *
+ * Returns the localized data.
+ *
+ * Implemented types:
+ * - date
+ * - Creates a date
+ * - l10n-field: date
+ * - params: timestamp (int/string)
+ * - datetime
+ * - Creates date and time
+ * - l10n-field: datetime
+ * - params: timestamp (int/string)
+ * - time
+ * - Creates a time
+ * - l10n-field: time
+ * - params: timestamp (int/string)
+ */
+ public function l($type, $data);
+}
diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php
new file mode 100644
index 00000000000..f89e790c1d0
--- /dev/null
+++ b/lib/public/inavigationmanager.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Manages the ownCloud navigation
+ */
+interface INavigationManager {
+ /**
+ * Creates a new navigation entry
+ * @param array $entry containing: id, name, order, icon and href key
+ */
+ public function add(array $entry);
+
+ /**
+ * Sets the current navigation entry of the currently running app
+ * @param string $appId id of the app entry to activate (from added $entry)
+ */
+ public function setActiveEntry($appId);
+}
diff --git a/lib/public/ipreview.php b/lib/public/ipreview.php
new file mode 100644
index 00000000000..b01e7f5b539
--- /dev/null
+++ b/lib/public/ipreview.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
+ * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+namespace OCP;
+
+/**
+ * This class provides functions to render and show thumbnails and previews of files
+ */
+interface IPreview
+{
+
+ /**
+ * @brief return a preview of a file
+ * @param string $file The path to the file where you want a thumbnail from
+ * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
+ * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
+ * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
+ * @return \OCP\Image
+ */
+ function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
+
+
+ /**
+ * @brief returns true if the passed mime type is supported
+ * @param string $mimeType
+ * @return boolean
+ */
+ function isMimeSupported($mimeType = '*');
+
+}
diff --git a/lib/public/irequest.php b/lib/public/irequest.php
new file mode 100644
index 00000000000..45b27868d70
--- /dev/null
+++ b/lib/public/irequest.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * This interface provides an immutable object with with accessors to
+ * request variables and headers.
+ *
+ * Access request variables by method and name.
+ *
+ * Examples:
+ *
+ * $request->post['myvar']; // Only look for POST variables
+ * $request->myvar; or $request->{'myvar'}; or $request->{$myvar}
+ * Looks in the combined GET, POST and urlParams array.
+ *
+ * If you access e.g. ->post but the current HTTP request method
+ * is GET a \LogicException will be thrown.
+ *
+ * NOTE:
+ * - When accessing ->put a stream resource is returned and the accessor
+ * will return false on subsequent access to ->put or ->patch.
+ * - When accessing ->patch and the Content-Type is either application/json
+ * or application/x-www-form-urlencoded (most cases) it will act like ->get
+ * and ->post and return an array. Otherwise the raw data will be returned.
+ */
+
+interface IRequest {
+
+ function getHeader($name);
+
+ /**
+ * Lets you access post and get parameters by the index
+ * In case of json requests the encoded json body is accessed
+ *
+ * @param string $key the key which you want to access in the URL Parameter
+ * placeholder, $_POST or $_GET array.
+ * The priority how they're returned is the following:
+ * 1. URL parameters
+ * 2. POST parameters
+ * 3. GET parameters
+ * @param mixed $default If the key is not found, this value will be returned
+ * @return mixed the content of the array
+ */
+ public function getParam($key, $default = null);
+
+
+ /**
+ * Returns all params that were received, be it from the request
+ *
+ * (as GET or POST) or through the URL by the route
+ * @return array the array with all parameters
+ */
+ public function getParams();
+
+ /**
+ * Returns the method of the request
+ *
+ * @return string the method of the request (POST, GET, etc)
+ */
+ public function getMethod();
+
+ /**
+ * Shortcut for accessing an uploaded file through the $_FILES array
+ *
+ * @param string $key the key that will be taken from the $_FILES array
+ * @return array the file in the $_FILES element
+ */
+ public function getUploadedFile($key);
+
+
+ /**
+ * Shortcut for getting env variables
+ *
+ * @param string $key the key that will be taken from the $_ENV array
+ * @return array the value in the $_ENV element
+ */
+ public function getEnv($key);
+
+
+ /**
+ * Shortcut for getting cookie variables
+ *
+ * @param string $key the key that will be taken from the $_COOKIE array
+ * @return array the value in the $_COOKIE element
+ */
+ function getCookie($key);
+
+
+ /**
+ * Checks if the CSRF check was correct
+ * @return bool true if CSRF check passed
+ */
+ public function passesCSRFCheck();
+}
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
new file mode 100644
index 00000000000..3afb2b6599d
--- /dev/null
+++ b/lib/public/iservercontainer.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+
+/**
+ * Class IServerContainer
+ * @package OCP
+ *
+ * This container holds all ownCloud services
+ */
+interface IServerContainer {
+
+ /**
+ * The contacts manager will act as a broker between consumers for contacts information and
+ * providers which actual deliver the contact information.
+ *
+ * @return \OCP\Contacts\IManager
+ */
+ function getContactsManager();
+
+ /**
+ * The current request object holding all information about the request currently being processed
+ * is returned from this method.
+ * In case the current execution was not initiated by a web request null is returned
+ *
+ * @return \OCP\IRequest|null
+ */
+ function getRequest();
+
+ /**
+ * Returns the preview manager which can create preview images for a given file
+ *
+ * @return \OCP\IPreview
+ */
+ function getPreviewManager();
+
+ /**
+ * Returns the tag manager which can get and set tags for different object types
+ *
+ * @see \OCP\ITagManager::load()
+ * @return \OCP\ITagManager
+ */
+ function getTagManager();
+
+ /**
+ * Returns the root folder of ownCloud's data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getRootFolder();
+
+ /**
+ * Returns a view to ownCloud's files folder
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getUserFolder();
+
+ /**
+ * Returns an app-specific view in ownClouds data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getAppFolder();
+
+ /**
+ * Returns the user session
+ *
+ * @return \OCP\IUserSession
+ */
+ function getUserSession();
+
+ /**
+ * @return \OCP\INavigationManager
+ */
+ function getNavigationManager();
+
+ /**
+ * @return \OCP\IConfig
+ */
+ function getConfig();
+
+ /**
+ * get an L10N instance
+ * @param $app string appid
+ * @return \OCP\IL10N
+ */
+ function getL10N($app);
+
+ /**
+ * @return \OCP\IURLGenerator
+ */
+ function getURLGenerator();
+
+ /**
+ * @return \OCP\IHelper
+ */
+ function getHelper();
+
+ /**
+ * Returns an ICache instance
+ *
+ * @return \OCP\ICache
+ */
+ function getCache();
+
+ /**
+ * Returns the current session
+ *
+ * @return \OCP\ISession
+ */
+ function getSession();
+
+ /**
+ * Returns the current session
+ *
+ * @return \OCP\IDBConnection
+ */
+ function getDatabaseConnection();
+
+}
diff --git a/lib/public/isession.php b/lib/public/isession.php
new file mode 100644
index 00000000000..0a77b0c823b
--- /dev/null
+++ b/lib/public/isession.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
+ * @author Thomas Tanghus
+ * @author Robin Appelman
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP;
+
+/**
+ * Interface ISession
+ *
+ * wrap PHP's internal session handling into the ISession interface
+ */
+interface ISession {
+
+ /**
+ * Set a value in the session
+ *
+ * @param string $key
+ * @param mixed $value
+ */
+ public function set($key, $value);
+
+ /**
+ * Get a value from the session
+ *
+ * @param string $key
+ * @return mixed should return null if $key does not exist
+ */
+ public function get($key);
+
+ /**
+ * Check if a named key exists in the session
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function exists($key);
+
+ /**
+ * Remove a $key/$value pair from the session
+ *
+ * @param string $key
+ */
+ public function remove($key);
+
+ /**
+ * Reset and recreate the session
+ */
+ public function clear();
+
+}
diff --git a/lib/public/itagmanager.php b/lib/public/itagmanager.php
new file mode 100644
index 00000000000..07e1d12fc0f
--- /dev/null
+++ b/lib/public/itagmanager.php
@@ -0,0 +1,48 @@
+<?php
+/**
+* ownCloud
+*
+* @author Thomas Tanghus
+* @copyright 2013 Thomas Tanghus <thomas@tanghus.net>
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+/**
+ * Factory class creating instances of \OCP\ITags
+ *
+ * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
+ * anything else that is either parsed from a vobject or that the user chooses
+ * to add.
+ * Tag names are not case-sensitive, but will be saved with the case they
+ * are entered in. If a user already has a tag 'family' for a type, and
+ * tries to add a tag named 'Family' it will be silently ignored.
+ */
+
+namespace OCP;
+
+interface ITagManager {
+
+ /**
+ * Create a new \OCP\ITags instance and load tags from db.
+ *
+ * @see \OCP\ITags
+ * @param string $type The type identifier e.g. 'contact' or 'event'.
+ * @param array $defaultTags An array of default tags to be used if none are stored.
+ * @return \OCP\ITags
+ */
+ public function load($type, $defaultTags=array());
+
+} \ No newline at end of file
diff --git a/lib/public/itags.php b/lib/public/itags.php
new file mode 100644
index 00000000000..5b1ebd189da
--- /dev/null
+++ b/lib/public/itags.php
@@ -0,0 +1,164 @@
+<?php
+/**
+* ownCloud
+*
+* @author Thomas Tanghus
+* @copyright 2013 Thomas Tanghus <thomas@tanghus.net>
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+namespace OCP;
+
+// FIXME: Where should I put this? Or should it be implemented as a Listener?
+\OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Tags', 'post_deleteUser');
+
+/**
+ * Class for easily tagging objects by their id
+ *
+ * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
+ * anything else that is either parsed from a vobject or that the user chooses
+ * to add.
+ * Tag names are not case-sensitive, but will be saved with the case they
+ * are entered in. If a user already has a tag 'family' for a type, and
+ * tries to add a tag named 'Family' it will be silently ignored.
+ */
+
+interface ITags {
+
+ /**
+ * Check if any tags are saved for this type and user.
+ *
+ * @return boolean.
+ */
+ public function isEmpty();
+
+ /**
+ * Get the tags for a specific user.
+ *
+ * This returns an array with id/name maps:
+ * [
+ * ['id' => 0, 'name' = 'First tag'],
+ * ['id' => 1, 'name' = 'Second tag'],
+ * ]
+ *
+ * @returns array
+ */
+ public function getTags();
+
+ /**
+ * Get the a list if items tagged with $tag.
+ *
+ * Throws an exception if the tag could not be found.
+ *
+ * @param string|integer $tag Tag id or name.
+ * @return array An array of object ids or false on error.
+ */
+ public function getIdsForTag($tag);
+
+ /**
+ * Checks whether a tag is already saved.
+ *
+ * @param string $name The name to check for.
+ * @return bool
+ */
+ public function hasTag($name);
+
+ /**
+ * Add a new tag.
+ *
+ * @param string $name A string with a name of the tag
+ * @return int the id of the added tag or false if it already exists.
+ */
+ public function add($name);
+
+ /**
+ * Rename tag.
+ *
+ * @param string $from The name of the existing tag
+ * @param string $to The new name of the tag.
+ * @return bool
+ */
+ public function rename($from, $to);
+
+ /**
+ * Add a list of new tags.
+ *
+ * @param string[] $names A string with a name or an array of strings containing
+ * the name(s) of the to add.
+ * @param bool $sync When true, save the tags
+ * @param int|null $id int Optional object id to add to this|these tag(s)
+ * @return bool Returns false on error.
+ */
+ public function addMultiple($names, $sync=false, $id = null);
+
+ /**
+ * Delete tag/object relations from the db
+ *
+ * @param array $ids The ids of the objects
+ * @return boolean Returns false on error.
+ */
+ public function purgeObjects(array $ids);
+
+ /**
+ * Get favorites for an object type
+ *
+ * @return array An array of object ids.
+ */
+ public function getFavorites();
+
+ /**
+ * Add an object to favorites
+ *
+ * @param int $objid The id of the object
+ * @return boolean
+ */
+ public function addToFavorites($objid);
+
+ /**
+ * Remove an object from favorites
+ *
+ * @param int $objid The id of the object
+ * @return boolean
+ */
+ public function removeFromFavorites($objid);
+
+ /**
+ * Creates a tag/object relation.
+ *
+ * @param int $objid The id of the object
+ * @param int|string $tag The id or name of the tag
+ * @return boolean Returns false on database error.
+ */
+ public function tagAs($objid, $tag);
+
+ /**
+ * Delete single tag/object relation from the db
+ *
+ * @param int $objid The id of the object
+ * @param int|string $tag The id or name of the tag
+ * @return boolean
+ */
+ public function unTag($objid, $tag);
+
+ /**
+ * Delete tags from the
+ *
+ * @param string[] $names An array of tags to delete
+ * @return bool Returns false on error
+ */
+ public function delete($names);
+
+} \ No newline at end of file
diff --git a/lib/public/iurlgenerator.php b/lib/public/iurlgenerator.php
new file mode 100644
index 00000000000..4eb4c0f8312
--- /dev/null
+++ b/lib/public/iurlgenerator.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Class to generate URLs
+ */
+interface IURLGenerator {
+ /**
+ * Returns the URL for a route
+ * @param string $routeName the name of the route
+ * @param array $arguments an array with arguments which will be filled into the url
+ * @return string the url
+ */
+ public function linkToRoute($routeName, $arguments = array());
+
+ /**
+ * Returns an URL for an image or file
+ * @param string $appName the name of the app
+ * @param string $file the name of the file
+ * @return string the url
+ */
+ public function linkTo($appName, $file);
+
+ /**
+ * Returns the link to an image, like linkTo but only with prepending img/
+ * @param string $appName the name of the app
+ * @param string $file the name of the file
+ * @return string the url
+ */
+ public function imagePath($appName, $file);
+
+
+ /**
+ * Makes an URL absolute
+ * @param string $url the url in the owncloud host
+ * @return string the absolute version of the url
+ */
+ public function getAbsoluteURL($url);
+}
diff --git a/lib/public/iusersession.php b/lib/public/iusersession.php
new file mode 100644
index 00000000000..5dc1ecf71e6
--- /dev/null
+++ b/lib/public/iusersession.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * User session
+ */
+interface IUserSession {
+ /**
+ * Do a user login
+ * @param string $user the username
+ * @param string $password the password
+ * @return bool true if successful
+ */
+ public function login($user, $password);
+
+ /**
+ * @brief Logs the user out including all the session data
+ * Logout, destroys session
+ */
+ public function logout();
+
+}
diff --git a/lib/public/preview.php b/lib/public/preview.php
deleted file mode 100644
index 7588347eccb..00000000000
--- a/lib/public/preview.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
- * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-namespace OCP;
-
-/**
- * This class provides functions to render and show thumbnails and previews of files
- */
-class Preview {
-
- /**
- * @brief return a preview of a file
- * @param $file The path to the file where you want a thumbnail from
- * @param $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
- * @param $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
- * @param $scaleup Scale smaller images up to the thumbnail size or not. Might look ugly
- * @return image
- */
- public static function show($file,$maxX=100,$maxY=75,$scaleup=false) {
- return(\OC\Preview::show($file,$maxX,$maxY,$scaleup));
- }
-
-
-
- public static function isMimeSupported($mimetype='*') {
- return \OC\Preview::isMimeSupported($mimetype);
- }
-
-}
diff --git a/lib/public/share.php b/lib/public/share.php
index 6c5783f1179..e6a74117aa2 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -246,9 +246,9 @@ class Share {
/**
* @brief Get the item of item type shared with the current user
- * @param string Item type
- * @param string Item target
- * @param int Format (optional) Format type must be defined by the backend
+ * @param string $itemType
+ * @param string $ItemTarget
+ * @param int $format (optional) Format type must be defined by the backend
* @return Return depends on format
*/
public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE,
@@ -258,6 +258,55 @@ class Share {
}
/**
+ * @brief Get the item of item type shared with a given user by source
+ * @param string $ItemType
+ * @param string $ItemSource
+ * @param string $user User user to whom the item was shared
+ * @return array Return list of items with file_target, permissions and expiration
+ */
+ public static function getItemSharedWithUser($itemType, $itemSource, $user) {
+
+ $shares = array();
+
+ // first check if there is a db entry for the specific user
+ $query = \OC_DB::prepare(
+ 'SELECT `file_target`, `permissions`, `expiration`
+ FROM
+ `*PREFIX*share`
+ WHERE
+ `item_source` = ? AND `item_type` = ? AND `share_with` = ?'
+ );
+
+ $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, $user));
+
+ while ($row = $result->fetchRow()) {
+ $shares[] = $row;
+ }
+
+ //if didn't found a result than let's look for a group share.
+ if(empty($shares)) {
+ $groups = \OC_Group::getUserGroups($user);
+
+ $query = \OC_DB::prepare(
+ 'SELECT `file_target`, `permissions`, `expiration`
+ FROM
+ `*PREFIX*share`
+ WHERE
+ `item_source` = ? AND `item_type` = ? AND `share_with` in (?)'
+ );
+
+ $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups)));
+
+ while ($row = $result->fetchRow()) {
+ $shares[] = $row;
+ }
+ }
+
+ return $shares;
+
+ }
+
+ /**
* @brief Get the item of item type shared with the current user by source
* @param string Item type
* @param string Item source
@@ -653,6 +702,29 @@ class Share {
}
return false;
}
+ /**
+ * @brief sent status if users got informed by mail about share
+ * @param string $itemType
+ * @param string $itemSource
+ * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
+ * @param bool $status
+ */
+ public static function setSendMailStatus($itemType, $itemSource, $shareType, $status) {
+ $status = $status ? 1 : 0;
+
+ $query = \OC_DB::prepare(
+ 'UPDATE `*PREFIX*share`
+ SET `mail_send` = ?
+ WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ?');
+
+ $result = $query->execute(array($status, $itemType, $itemSource, $shareType));
+
+ if($result === false) {
+ \OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR);
+ }
+
+
+ }
/**
* @brief Set the permissions of an item for a specific user or group
@@ -983,19 +1055,19 @@ class Share {
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
- .' `share_type`, `file_source`, `path`, `expiration`, `storage`';
+ .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`';
}
} else {
if (isset($uidOwner)) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
.' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,'
- .' `expiration`, `token`, `storage`';
+ .' `expiration`, `token`, `storage`, `mail_send`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,'
- .' `stime`, `file_source`, `expiration`, `token`';
+ .' `stime`, `file_source`, `expiration`, `token`, `mail_send`';
}
} else {
if ($fileDependent) {
@@ -1006,11 +1078,11 @@ class Share {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, '
.'`share_type`, `share_with`, `file_source`, `path`, `file_target`, '
.'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, '
- .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`';
+ .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `mail_send`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`,
`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,
- `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`';
+ `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`';
}
} else {
$select = '*';
diff --git a/lib/public/template.php b/lib/public/template.php
index 3b1a4ed4906..a5c500b0e25 100644
--- a/lib/public/template.php
+++ b/lib/public/template.php
@@ -90,8 +90,8 @@ function human_file_size( $bytes ) {
* @param $timestamp unix timestamp
* @returns human readable interpretation of the timestamp
*/
-function relative_modified_date($timestamp) {
- return(\relative_modified_date($timestamp));
+function relative_modified_date($timestamp, $dateOnly = false) {
+ return(\relative_modified_date($timestamp, null, $dateOnly));
}
diff --git a/lib/urlgenerator.php b/lib/urlgenerator.php
new file mode 100644
index 00000000000..1db4c36cc58
--- /dev/null
+++ b/lib/urlgenerator.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OC;
+
+/**
+ * Class to generate URLs
+ */
+class URLGenerator {
+ /**
+ * @brief Creates an url using a defined route
+ * @param $route
+ * @param array $parameters
+ * @return
+ * @internal param array $args with param=>value, will be appended to the returned url
+ * @returns the url
+ *
+ * Returns a url to the given app and file.
+ */
+ public function linkToRoute($route, $parameters = array()) {
+ $urlLinkTo = \OC::getRouter()->generate($route, $parameters);
+ return $urlLinkTo;
+ }
+
+ /**
+ * @brief Creates an url
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * The value of $args will be urlencoded
+ * @return string the url
+ *
+ * Returns a url to the given app and file.
+ */
+ public function linkTo( $app, $file, $args = array() ) {
+ if( $app != '' ) {
+ $app_path = \OC_App::getAppPath($app);
+ // Check if the app is in the app folder
+ if ($app_path && file_exists($app_path . '/' . $file)) {
+ if (substr($file, -3) == 'php' || substr($file, -3) == 'css') {
+ $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app;
+ $urlLinkTo .= ($file != 'index.php') ? '/' . $file : '';
+ } else {
+ $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file;
+ }
+ } else {
+ $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file;
+ }
+ } else {
+ if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) {
+ $urlLinkTo = \OC::$WEBROOT . '/core/' . $file;
+ } else {
+ $urlLinkTo = \OC::$WEBROOT . '/' . $file;
+ }
+ }
+
+ if ($args && $query = http_build_query($args, '', '&')) {
+ $urlLinkTo .= '?' . $query;
+ }
+
+ return $urlLinkTo;
+ }
+
+ /**
+ * @brief Creates path to an image
+ * @param string $app app
+ * @param string $image image name
+ * @return string the url
+ *
+ * Returns the path to the image.
+ */
+ public function imagePath($app, $image) {
+ // Read the selected theme from the config file
+ $theme = \OC_Util::getTheme();
+
+ // Check if the app is in the app folder
+ if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
+ return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
+ } elseif (file_exists(\OC_App::getAppPath($app) . "/img/$image")) {
+ return \OC_App::getAppWebPath($app) . "/img/$image";
+ } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
+ return \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
+ } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
+ return \OC::$WEBROOT . "/$app/img/$image";
+ } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
+ return \OC::$WEBROOT . "/themes/$theme/core/img/$image";
+ } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
+ return \OC::$WEBROOT . "/core/img/$image";
+ } else {
+ throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
+ }
+ }
+
+ /**
+ * @brief Makes an $url absolute
+ * @param string $url the url
+ * @return string the absolute url
+ *
+ * Returns a absolute url to the given app and file.
+ */
+ public function makeURLAbsolute($url) {
+ return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . $url;
+ }
+
+}
diff --git a/lib/vcategories.php b/lib/vcategories.php
deleted file mode 100644
index 84036958359..00000000000
--- a/lib/vcategories.php
+++ /dev/null
@@ -1,821 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Thomas Tanghus
-* @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
-* @copyright 2012 Bart Visscher bartv@thisnet.nl
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_VCategories', 'post_deleteUser');
-
-/**
- * Class for easy access to categories in VCARD, VEVENT, VTODO and VJOURNAL.
- * A Category can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
- * anything else that is either parsed from a vobject or that the user chooses
- * to add.
- * Category names are not case-sensitive, but will be saved with the case they
- * are entered in. If a user already has a category 'family' for a type, and
- * tries to add a category named 'Family' it will be silently ignored.
- */
-class OC_VCategories {
-
- /**
- * Categories
- */
- private $categories = array();
-
- /**
- * Used for storing objectid/categoryname pairs while rescanning.
- */
- private static $relations = array();
-
- private $type = null;
- private $user = null;
-
- const CATEGORY_TABLE = '*PREFIX*vcategory';
- const RELATION_TABLE = '*PREFIX*vcategory_to_object';
-
- const CATEGORY_FAVORITE = '_$!<Favorite>!$_';
-
- const FORMAT_LIST = 0;
- const FORMAT_MAP = 1;
-
- /**
- * @brief Constructor.
- * @param $type The type identifier e.g. 'contact' or 'event'.
- * @param $user The user whos data the object will operate on. This
- * parameter should normally be omitted but to make an app able to
- * update categories for all users it is made possible to provide it.
- * @param $defcategories An array of default categories to be used if none is stored.
- */
- public function __construct($type, $user=null, $defcategories=array()) {
- $this->type = $type;
- $this->user = is_null($user) ? OC_User::getUser() : $user;
-
- $this->loadCategories();
- OCP\Util::writeLog('core', __METHOD__ . ', categories: '
- . print_r($this->categories, true),
- OCP\Util::DEBUG
- );
-
- if($defcategories && count($this->categories) === 0) {
- $this->addMulti($defcategories, true);
- }
- }
-
- /**
- * @brief Load categories from db.
- */
- private function loadCategories() {
- $this->categories = array();
- $result = null;
- $sql = 'SELECT `id`, `category` FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ? AND `type` = ? ORDER BY `category`';
- try {
- $stmt = OCP\DB::prepare($sql);
- $result = $stmt->execute(array($this->user, $this->type));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
-
- if(!is_null($result)) {
- while( $row = $result->fetchRow()) {
- // The keys are prefixed because array_search wouldn't work otherwise :-/
- $this->categories[$row['id']] = $row['category'];
- }
- }
- OCP\Util::writeLog('core', __METHOD__.', categories: ' . print_r($this->categories, true),
- OCP\Util::DEBUG);
- }
-
-
- /**
- * @brief Check if any categories are saved for this type and user.
- * @returns boolean.
- * @param $type The type identifier e.g. 'contact' or 'event'.
- * @param $user The user whos categories will be checked. If not set current user will be used.
- */
- public static function isEmpty($type, $user = null) {
- $user = is_null($user) ? OC_User::getUser() : $user;
- $sql = 'SELECT COUNT(*) FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ? AND `type` = ?';
- try {
- $stmt = OCP\DB::prepare($sql);
- $result = $stmt->execute(array($user, $type));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- return ($result->numRows() === 0);
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- }
-
- /**
- * @brief Get the categories for a specific user.
- * @param
- * @returns array containing the categories as strings.
- */
- public function categories($format = null) {
- if(!$this->categories) {
- return array();
- }
- $categories = array_values($this->categories);
- uasort($categories, 'strnatcasecmp');
- if($format == self::FORMAT_MAP) {
- $catmap = array();
- foreach($categories as $category) {
- if($category !== self::CATEGORY_FAVORITE) {
- $catmap[] = array(
- 'id' => $this->array_searchi($category, $this->categories),
- 'name' => $category
- );
- }
- }
- return $catmap;
- }
-
- // Don't add favorites to normal categories.
- $favpos = array_search(self::CATEGORY_FAVORITE, $categories);
- if($favpos !== false) {
- return array_splice($categories, $favpos);
- } else {
- return $categories;
- }
- }
-
- /**
- * Get the a list if items belonging to $category.
- *
- * Throws an exception if the category could not be found.
- *
- * @param string|integer $category Category id or name.
- * @returns array An array of object ids or false on error.
- */
- public function idsForCategory($category) {
- $result = null;
- if(is_numeric($category)) {
- $catid = $category;
- } elseif(is_string($category)) {
- $catid = $this->array_searchi($category, $this->categories);
- }
- OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
- if($catid === false) {
- $l10n = OC_L10N::get('core');
- throw new Exception(
- $l10n->t('Could not find category "%s"', $category)
- );
- }
-
- $ids = array();
- $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE
- . '` WHERE `categoryid` = ?';
-
- try {
- $stmt = OCP\DB::prepare($sql);
- $result = $stmt->execute(array($catid));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
-
- if(!is_null($result)) {
- while( $row = $result->fetchRow()) {
- $ids[] = (int)$row['objid'];
- }
- }
-
- return $ids;
- }
-
- /**
- * Get the a list if items belonging to $category.
- *
- * Throws an exception if the category could not be found.
- *
- * @param string|integer $category Category id or name.
- * @param array $tableinfo Array in the form {'tablename' => table, 'fields' => ['field1', 'field2']}
- * @param int $limit
- * @param int $offset
- *
- * This generic method queries a table assuming that the id
- * field is called 'id' and the table name provided is in
- * the form '*PREFIX*table_name'.
- *
- * If the category name cannot be resolved an exception is thrown.
- *
- * TODO: Maybe add the getting permissions for objects?
- *
- * @returns array containing the resulting items or false on error.
- */
- public function itemsForCategory($category, $tableinfo, $limit = null, $offset = null) {
- $result = null;
- if(is_numeric($category)) {
- $catid = $category;
- } elseif(is_string($category)) {
- $catid = $this->array_searchi($category, $this->categories);
- }
- OCP\Util::writeLog('core', __METHOD__.', category: '.$catid.' '.$category, OCP\Util::DEBUG);
- if($catid === false) {
- $l10n = OC_L10N::get('core');
- throw new Exception(
- $l10n->t('Could not find category "%s"', $category)
- );
- }
- $fields = '';
- foreach($tableinfo['fields'] as $field) {
- $fields .= '`' . $tableinfo['tablename'] . '`.`' . $field . '`,';
- }
- $fields = substr($fields, 0, -1);
-
- $items = array();
- $sql = 'SELECT `' . self::RELATION_TABLE . '`.`categoryid`, ' . $fields
- . ' FROM `' . $tableinfo['tablename'] . '` JOIN `'
- . self::RELATION_TABLE . '` ON `' . $tableinfo['tablename']
- . '`.`id` = `' . self::RELATION_TABLE . '`.`objid` WHERE `'
- . self::RELATION_TABLE . '`.`categoryid` = ?';
-
- try {
- $stmt = OCP\DB::prepare($sql, $limit, $offset);
- $result = $stmt->execute(array($catid));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
-
- if(!is_null($result)) {
- while( $row = $result->fetchRow()) {
- $items[] = $row;
- }
- }
- //OCP\Util::writeLog('core', __METHOD__.', count: ' . count($items), OCP\Util::DEBUG);
- //OCP\Util::writeLog('core', __METHOD__.', sql: ' . $sql, OCP\Util::DEBUG);
-
- return $items;
- }
-
- /**
- * @brief Checks whether a category is already saved.
- * @param $name The name to check for.
- * @returns bool
- */
- public function hasCategory($name) {
- return $this->in_arrayi($name, $this->categories);
- }
-
- /**
- * @brief Add a new category.
- * @param $name A string with a name of the category
- * @returns int the id of the added category or false if it already exists.
- */
- public function add($name) {
- OCP\Util::writeLog('core', __METHOD__.', name: ' . $name, OCP\Util::DEBUG);
- if($this->hasCategory($name)) {
- OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', OCP\Util::DEBUG);
- return false;
- }
- try {
- OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
- array(
- 'uid' => $this->user,
- 'type' => $this->type,
- 'category' => $name,
- ));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- $id = OCP\DB::insertid(self::CATEGORY_TABLE);
- OCP\Util::writeLog('core', __METHOD__.', id: ' . $id, OCP\Util::DEBUG);
- $this->categories[$id] = $name;
- return $id;
- }
-
- /**
- * @brief Rename category.
- * @param string $from The name of the existing category
- * @param string $to The new name of the category.
- * @returns bool
- */
- public function rename($from, $to) {
- $id = $this->array_searchi($from, $this->categories);
- if($id === false) {
- OCP\Util::writeLog('core', __METHOD__.', category: ' . $from. ' does not exist', OCP\Util::DEBUG);
- return false;
- }
-
- $sql = 'UPDATE `' . self::CATEGORY_TABLE . '` SET `category` = ? '
- . 'WHERE `uid` = ? AND `type` = ? AND `id` = ?';
- try {
- $stmt = OCP\DB::prepare($sql);
- $result = $stmt->execute(array($to, $this->user, $this->type, $id));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- $this->categories[$id] = $to;
- return true;
- }
-
- /**
- * @brief Add a new category.
- * @param $names A string with a name or an array of strings containing
- * the name(s) of the categor(y|ies) to add.
- * @param $sync bool When true, save the categories
- * @param $id int Optional object id to add to this|these categor(y|ies)
- * @returns bool Returns false on error.
- */
- public function addMulti($names, $sync=false, $id = null) {
- if(!is_array($names)) {
- $names = array($names);
- }
- $names = array_map('trim', $names);
- $newones = array();
- foreach($names as $name) {
- if(($this->in_arrayi(
- $name, $this->categories) == false) && $name != '') {
- $newones[] = $name;
- }
- if(!is_null($id) ) {
- // Insert $objectid, $categoryid pairs if not exist.
- self::$relations[] = array('objid' => $id, 'category' => $name);
- }
- }
- $this->categories = array_merge($this->categories, $newones);
- if($sync === true) {
- $this->save();
- }
-
- return true;
- }
-
- /**
- * @brief Extracts categories from a vobject and add the ones not already present.
- * @param $vobject The instance of OC_VObject to load the categories from.
- */
- public function loadFromVObject($id, $vobject, $sync=false) {
- $this->addMulti($vobject->getAsArray('CATEGORIES'), $sync, $id);
- }
-
- /**
- * @brief Reset saved categories and rescan supplied vobjects for categories.
- * @param $objects An array of vobjects (as text).
- * To get the object array, do something like:
- * // For Addressbook:
- * $categories = new OC_VCategories('contacts');
- * $stmt = OC_DB::prepare( 'SELECT `carddata` FROM `*PREFIX*contacts_cards`' );
- * $result = $stmt->execute();
- * $objects = array();
- * if(!is_null($result)) {
- * while( $row = $result->fetchRow()){
- * $objects[] = array($row['id'], $row['carddata']);
- * }
- * }
- * $categories->rescan($objects);
- */
- public function rescan($objects, $sync=true, $reset=true) {
-
- if($reset === true) {
- $result = null;
- // Find all objectid/categoryid pairs.
- try {
- $stmt = OCP\DB::prepare('SELECT `id` FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ? AND `type` = ?');
- $result = $stmt->execute(array($this->user, $this->type));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
-
- // And delete them.
- if(!is_null($result)) {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `categoryid` = ? AND `type`= ?');
- while( $row = $result->fetchRow()) {
- $stmt->execute(array($row['id'], $this->type));
- }
- }
- try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ? AND `type` = ?');
- $result = $stmt->execute(array($this->user, $this->type));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__ . ', exception: '
- . $e->getMessage(), OCP\Util::ERROR);
- return;
- }
- $this->categories = array();
- }
- // Parse all the VObjects
- foreach($objects as $object) {
- $vobject = OC_VObject::parse($object[1]);
- if(!is_null($vobject)) {
- // Load the categories
- $this->loadFromVObject($object[0], $vobject, $sync);
- } else {
- OC_Log::write('core', __METHOD__ . ', unable to parse. ID: ' . ', '
- . substr($object, 0, 100) . '(...)', OC_Log::DEBUG);
- }
- }
- $this->save();
- }
-
- /**
- * @brief Save the list with categories
- */
- private function save() {
- if(is_array($this->categories)) {
- foreach($this->categories as $category) {
- try {
- OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
- array(
- 'uid' => $this->user,
- 'type' => $this->type,
- 'category' => $category,
- ));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
- }
- // reload categories to get the proper ids.
- $this->loadCategories();
- // Loop through temporarily cached objectid/categoryname pairs
- // and save relations.
- $categories = $this->categories;
- // For some reason this is needed or array_search(i) will return 0..?
- ksort($categories);
- foreach(self::$relations as $relation) {
- $catid = $this->array_searchi($relation['category'], $categories);
- OC_Log::write('core', __METHOD__ . 'catid, ' . $relation['category'] . ' ' . $catid, OC_Log::DEBUG);
- if($catid) {
- try {
- OCP\DB::insertIfNotExist(self::RELATION_TABLE,
- array(
- 'objid' => $relation['objid'],
- 'categoryid' => $catid,
- 'type' => $this->type,
- ));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
- }
- }
- self::$relations = array(); // reset
- } else {
- OC_Log::write('core', __METHOD__.', $this->categories is not an array! '
- . print_r($this->categories, true), OC_Log::ERROR);
- }
- }
-
- /**
- * @brief Delete categories and category/object relations for a user.
- * For hooking up on post_deleteUser
- * @param string $uid The user id for which entries should be purged.
- */
- public static function post_deleteUser($arguments) {
- // Find all objectid/categoryid pairs.
- $result = null;
- try {
- $stmt = OCP\DB::prepare('SELECT `id` FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ?');
- $result = $stmt->execute(array($arguments['uid']));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
-
- if(!is_null($result)) {
- try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `categoryid` = ?');
- while( $row = $result->fetchRow()) {
- try {
- $stmt->execute(array($row['id']));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- }
- }
- try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::CATEGORY_TABLE . '` '
- . 'WHERE `uid` = ?');
- $result = $stmt->execute(array($arguments['uid']));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__ . ', exception: '
- . $e->getMessage(), OCP\Util::ERROR);
- }
- }
-
- /**
- * @brief Delete category/object relations from the db
- * @param array $ids The ids of the objects
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns boolean Returns false on error.
- */
- public function purgeObjects(array $ids, $type = null) {
- $type = is_null($type) ? $this->type : $type;
- if(count($ids) === 0) {
- // job done ;)
- return true;
- }
- $updates = $ids;
- try {
- $query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
- $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
- $query .= 'AND `type`= ?';
- $updates[] = $type;
- $stmt = OCP\DB::prepare($query);
- $result = $stmt->execute($updates);
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- return false;
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * Get favorites for an object type
- *
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns array An array of object ids.
- */
- public function getFavorites($type = null) {
- $type = is_null($type) ? $this->type : $type;
-
- try {
- return $this->idsForCategory(self::CATEGORY_FAVORITE);
- } catch(Exception $e) {
- // No favorites
- return array();
- }
- }
-
- /**
- * Add an object to favorites
- *
- * @param int $objid The id of the object
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns boolean
- */
- public function addToFavorites($objid, $type = null) {
- $type = is_null($type) ? $this->type : $type;
- if(!$this->hasCategory(self::CATEGORY_FAVORITE)) {
- $this->add(self::CATEGORY_FAVORITE, true);
- }
- return $this->addToCategory($objid, self::CATEGORY_FAVORITE, $type);
- }
-
- /**
- * Remove an object from favorites
- *
- * @param int $objid The id of the object
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns boolean
- */
- public function removeFromFavorites($objid, $type = null) {
- $type = is_null($type) ? $this->type : $type;
- return $this->removeFromCategory($objid, self::CATEGORY_FAVORITE, $type);
- }
-
- /**
- * @brief Creates a category/object relation.
- * @param int $objid The id of the object
- * @param int|string $category The id or name of the category
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns boolean Returns false on database error.
- */
- public function addToCategory($objid, $category, $type = null) {
- $type = is_null($type) ? $this->type : $type;
- if(is_string($category) && !is_numeric($category)) {
- if(!$this->hasCategory($category)) {
- $this->add($category, true);
- }
- $categoryid = $this->array_searchi($category, $this->categories);
- } else {
- $categoryid = $category;
- }
- try {
- OCP\DB::insertIfNotExist(self::RELATION_TABLE,
- array(
- 'objid' => $objid,
- 'categoryid' => $categoryid,
- 'type' => $type,
- ));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * @brief Delete single category/object relation from the db
- * @param int $objid The id of the object
- * @param int|string $category The id or name of the category
- * @param string $type The type of object (event/contact/task/journal).
- * Defaults to the type set in the instance
- * @returns boolean
- */
- public function removeFromCategory($objid, $category, $type = null) {
- $type = is_null($type) ? $this->type : $type;
- $categoryid = (is_string($category) && !is_numeric($category))
- ? $this->array_searchi($category, $this->categories)
- : $category;
- try {
- $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?';
- OCP\Util::writeLog('core', __METHOD__.', sql: ' . $objid . ' ' . $categoryid . ' ' . $type,
- OCP\Util::DEBUG);
- $stmt = OCP\DB::prepare($sql);
- $stmt->execute(array($objid, $categoryid, $type));
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- return true;
- }
-
- /**
- * @brief Delete categories from the db and from all the vobject supplied
- * @param $names An array of categories to delete
- * @param $objects An array of arrays with [id,vobject] (as text) pairs suitable for updating the apps object table.
- */
- public function delete($names, array &$objects=null) {
- if(!is_array($names)) {
- $names = array($names);
- }
-
- OC_Log::write('core', __METHOD__ . ', before: '
- . print_r($this->categories, true), OC_Log::DEBUG);
- foreach($names as $name) {
- $id = null;
- OC_Log::write('core', __METHOD__.', '.$name, OC_Log::DEBUG);
- if($this->hasCategory($name)) {
- $id = $this->array_searchi($name, $this->categories);
- unset($this->categories[$id]);
- }
- try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::CATEGORY_TABLE . '` WHERE '
- . '`uid` = ? AND `type` = ? AND `category` = ?');
- $result = $stmt->execute(array($this->user, $this->type, $name));
- if (OC_DB::isError($result)) {
- OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__ . ', exception: '
- . $e->getMessage(), OCP\Util::ERROR);
- }
- if(!is_null($id) && $id !== false) {
- try {
- $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `categoryid` = ?';
- $stmt = OCP\DB::prepare($sql);
- $result = $stmt->execute(array($id));
- if (OC_DB::isError($result)) {
- OC_Log::write('core',
- __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result),
- OC_Log::ERROR);
- }
- } catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
- OCP\Util::ERROR);
- return false;
- }
- }
- }
- OC_Log::write('core', __METHOD__.', after: '
- . print_r($this->categories, true), OC_Log::DEBUG);
- if(!is_null($objects)) {
- foreach($objects as $key=>&$value) {
- $vobject = OC_VObject::parse($value[1]);
- if(!is_null($vobject)) {
- $object = null;
- $componentname = '';
- if (isset($vobject->VEVENT)) {
- $object = $vobject->VEVENT;
- $componentname = 'VEVENT';
- } else
- if (isset($vobject->VTODO)) {
- $object = $vobject->VTODO;
- $componentname = 'VTODO';
- } else
- if (isset($vobject->VJOURNAL)) {
- $object = $vobject->VJOURNAL;
- $componentname = 'VJOURNAL';
- } else {
- $object = $vobject;
- }
- $categories = $object->getAsArray('CATEGORIES');
- foreach($names as $name) {
- $idx = $this->array_searchi($name, $categories);
- if($idx !== false) {
- OC_Log::write('core', __METHOD__
- .', unsetting: '
- . $categories[$this->array_searchi($name, $categories)],
- OC_Log::DEBUG);
- unset($categories[$this->array_searchi($name, $categories)]);
- }
- }
-
- $object->setString('CATEGORIES', implode(',', $categories));
- if($vobject !== $object) {
- $vobject[$componentname] = $object;
- }
- $value[1] = $vobject->serialize();
- $objects[$key] = $value;
- } else {
- OC_Log::write('core', __METHOD__
- .', unable to parse. ID: ' . $value[0] . ', '
- . substr($value[1], 0, 50) . '(...)', OC_Log::DEBUG);
- }
- }
- }
- }
-
- // case-insensitive in_array
- private function in_arrayi($needle, $haystack) {
- if(!is_array($haystack)) {
- return false;
- }
- return in_array(strtolower($needle), array_map('strtolower', $haystack));
- }
-
- // case-insensitive array_search
- private function array_searchi($needle, $haystack) {
- if(!is_array($haystack)) {
- return false;
- }
- return array_search(strtolower($needle), array_map('strtolower', $haystack));
- }
-}