diff --git a/appinfo/app.php b/appinfo/app.php index ab7ff9e..f87e851 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -31,5 +31,4 @@ $app = new Application(); // \AppInfo\Application(); $app->registerNavigationEntry(); -\OC\Share\Share::registerBackend ('nextnote', '\OCA\NextNote\ShareBackend\NextNoteShareBackend'); -\OCP\App::registerAdmin('nextnote', 'admin'); + diff --git a/appinfo/database.xml b/appinfo/database.xml index bd63d24..6ba1905 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -33,13 +33,6 @@ true 255 - - grouping - text - true - 255 - - notebook integer @@ -47,12 +40,6 @@ 32 - - shared - clob - true - - mtime integer diff --git a/appinfo/info.xml b/appinfo/info.xml index 9f4d6e1..aaf908e 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ NextNote NextNote NextNote - 1.2.4 + 1.2.5 agpl Ben Curtis Sander Brand diff --git a/controller/noteapicontroller.php b/controller/noteapicontroller.php index 0d13c8a..dde334b 100644 --- a/controller/noteapicontroller.php +++ b/controller/noteapicontroller.php @@ -25,12 +25,9 @@ use OCA\NextNote\Db\Notebook; use OCA\NextNote\Db\Note; -use OCA\NextNote\Fixtures\ShareFix; use OCA\NextNote\Service\NotebookService; use OCA\NextNote\Service\NoteService; -use OCA\NextNote\ShareBackend\NextNoteShareBackend; use OCA\NextNote\Utility\NotFoundJSONResponse; -use OCA\NextNote\Utility\UnauthorizedJSONResponse; use OCA\NextNote\Utility\Utils; use \OCP\AppFramework\ApiController; use OCP\AppFramework\Http\JSONResponse; @@ -39,28 +36,23 @@ use OCP\ILogger; use \OCP\IRequest; use OCP\IUserManager; -use OCP\Share; + class NoteApiController extends ApiController { private $config; private $noteService; - private $shareBackend; private $userManager; - private $shareManager; private $notebookService; public function __construct($appName, IRequest $request, - ILogger $logger, IConfig $config, NoteService $noteService, NotebookService $groupService, - NextNoteShareBackend $shareBackend, IUserManager $userManager, Share\IManager $shareManager) { + ILogger $logger, IConfig $config, NoteService $noteService, NotebookService $groupService,IUserManager $userManager) { parent::__construct($appName, $request); $this->config = $config; $this->noteService = $noteService; $this->notebookService = $groupService; - $this->shareBackend = $shareBackend; $this->userManager = $userManager; - $this->shareManager = $shareManager; } /** @@ -164,9 +156,7 @@ public function update($id, $title, $content, $deleted, $notebook_id) { $note->setGuid(Utils::GUID()); } - if (!$this->shareBackend->checkPermissions(Constants::PERMISSION_UPDATE, $note)) { - return new UnauthorizedJSONResponse(); - } + if(!empty($notebook_id)){ $notebook = $this->notebookService->find($notebook_id); if($notebook instanceof Notebook) { @@ -194,10 +184,6 @@ public function delete($id) { return new NotFoundJSONResponse(); } - if (!$this->shareBackend->checkPermissions(Constants::PERMISSION_DELETE, $entity)) { - return new UnauthorizedJSONResponse(); - } - $this->noteService->delete($id); $result = (object)['success' => true]; \OC_Hook::emit('OCA\NextNote', 'post_delete_note', ['note_id' => $id]); @@ -213,20 +199,11 @@ private function formatApiResponse($note) { $acl = [ 'permissions' => Constants::PERMISSION_ALL ]; - if ($uid !== $note['uid']) { - $aclRoles = ShareFix::getItemSharedWith('nextnote', $note['id'], 'populated_shares'); - $acl['permissions'] = $aclRoles['permissions']; - } + $note['owner'] = Utils::getUserInfo($note['uid']); $note['permissions'] = $acl['permissions']; - $shared_with = ShareFix::getUsersItemShared('nextnote', $note['id'], $note['uid']); - foreach ($shared_with as &$u) { - $info = Utils::getUserInfo($u); - if($info) { - $u = $info; - } - } + $shared_with = []; $note['shared_with'] = ($note['uid'] == $uid) ? $shared_with : [$uid]; unset($note['uid']); diff --git a/controller/notebookapicontroller.php b/controller/notebookapicontroller.php index 45ee79a..2830efd 100644 --- a/controller/notebookapicontroller.php +++ b/controller/notebookapicontroller.php @@ -24,36 +24,29 @@ namespace OCA\NextNote\Controller; use OCA\NextNote\Db\Notebook; -use OCA\NextNote\Fixtures\ShareFix; use OCA\NextNote\Service\NotebookService; -use OCA\NextNote\Service\NoteService; -use OCA\NextNote\ShareBackend\NextNoteShareBackend; use OCA\NextNote\Utility\NotFoundJSONResponse; use OCA\NextNote\Utility\UnauthorizedJSONResponse; use OCA\NextNote\Utility\Utils; use \OCP\AppFramework\ApiController; use OCP\AppFramework\Http\JSONResponse; -use OCP\Constants; use OCP\IConfig; use OCP\ILogger; use \OCP\IRequest; use OCP\IUserManager; -use OCP\Share; class NotebookApiController extends ApiController { private $config; private $notebookService; - private $shareBackend; private $userManager; public function __construct($appName, IRequest $request, - ILogger $logger, IConfig $config, NotebookService $notebookService, NextNoteShareBackend $shareBackend, IUserManager $userManager) { + ILogger $logger, IConfig $config, NotebookService $notebookService, IUserManager $userManager) { parent::__construct($appName, $request); $this->config = $config; $this->notebookService = $notebookService; - $this->shareBackend = $shareBackend; $this->userManager = $userManager; } diff --git a/controller/shareapicontroller.php b/controller/shareapicontroller.php index 0890e71..c930a03 100644 --- a/controller/shareapicontroller.php +++ b/controller/shareapicontroller.php @@ -13,8 +13,6 @@ use \OCP\AppFramework\ApiController; use \OCP\IRequest; -use OC\Share\Share; -use OCA\NextNote\Fixtures\ShareFix; class ShareApiController extends ApiController { @@ -28,9 +26,7 @@ public function __construct($appName, IRequest $request) { * @NoCSRFRequired */ public function getShares($noteid, $shared_with_me, $reshares) { - if ($reshares) { - return array_values(Share::getItemShared('nextnote', $noteid, 'shares')); - } + } /** @@ -38,15 +34,7 @@ public function getShares($noteid, $shared_with_me, $reshares) { * @NoCSRFRequired */ public function share($noteid, $shareType, $shareWith, $publicUpload, $password, $permissions) { - $shareType = intval($shareType); - //Todo check if resharing is allowed - if($shareType === 1){ - $result = ShareFix::shareItem('nextnote', intval($noteid), intval($shareType), $shareWith, intval($permissions)); - } else { - $result = Share::shareItem('nextnote', intval($noteid), intval($shareType), $shareWith, intval($permissions)); - } - \OC_Hook::emit('OCA\NextNote', 'post_share_note', ['note_id' => $noteid]); - return $result; + } /** @@ -54,9 +42,7 @@ public function share($noteid, $shareType, $shareWith, $publicUpload, $password, * @NoCSRFRequired */ public function unshare($itemSource, $shareType, $shareWith) { - $result = Share::unshare('nextnote', intval($itemSource), intval($shareType), $shareWith); - \OC_Hook::emit('OCA\NextNote', 'post_unshare_note', ['note_id' => $itemSource]); - return $result; + } /** @@ -64,8 +50,6 @@ public function unshare($itemSource, $shareType, $shareWith) { * @NoCSRFRequired */ public function setpermissions($itemSource, $shareType, $shareWith, $permissions) { - $result = ShareFix::setPermissions('nextnote', intval($itemSource), intval($shareType), $shareWith, intval($permissions)); - \OC_Hook::emit('OCA\NextNote', 'post_update_note_share_permissions', ['note_id' => $itemSource]); - return $result; + } } \ No newline at end of file diff --git a/controller/translationcontroller.php b/controller/translationcontroller.php index 2687bd0..b176a32 100644 --- a/controller/translationcontroller.php +++ b/controller/translationcontroller.php @@ -23,25 +23,11 @@ namespace OCA\NextNote\Controller; -use OCA\NextNote\Db\Notebook; -use OCA\NextNote\Db\Note; -use OCA\NextNote\Fixtures\ShareFix; -use OCA\NextNote\Service\NotebookService; -use OCA\NextNote\Service\NoteService; -use OCA\NextNote\ShareBackend\NextNoteShareBackend; -use OCA\NextNote\Utility\NotFoundJSONResponse; -use OCA\NextNote\Utility\UnauthorizedJSONResponse; -use OCA\NextNote\Utility\Utils; + use \OCP\AppFramework\ApiController; use OCP\AppFramework\Http\JSONResponse; -use OCP\Constants; -use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use \OCP\IRequest; -use OCP\IUserManager; -use OCP\Share; - class TranslationController extends ApiController { diff --git a/js/animations.js b/js/animations.js new file mode 100644 index 0000000..2889dd1 --- /dev/null +++ b/js/animations.js @@ -0,0 +1,33 @@ +$(document).ready(function () { + var isSingleViewMode = (app_config.user.view_mode === 'single'); + var $body = $('body'); + if(isSingleViewMode){ + $('#ownnote').find('.view-container').width('200%'); + } + $body.on('click', '.file.pointer, #new', function (e) { + if ($(window).width() <= 994 || isSingleViewMode) { + setTimeout(function () { + $('#ownnote').animate({scrollLeft: $(window).width()}, 750); + }, 50); + } + }); + $body.on('click', '#canceledit, #grouplist .group', function (e) { + if ($(window).width() <= 994 || isSingleViewMode) { + $('#ownnote').animate({scrollLeft: 0}, 750); + } + }); + + $body.on('click', '.toggle-view-mode', function () { + if(app_config.user.view_mode === 'single') { + $('#ownnote').find('.view-container').animate({width: '100%'}, 750); + $(this).find('i').removeClass('fa-arrows-h').addClass('fa-columns'); + isSingleViewMode = false; + app_config.user.view_mode = 'col'; + } else if(app_config.user.view_mode === 'col'){ + $('#ownnote').find('.view-container').animate({width: '200%'}, 750); + $(this).find('i').removeClass('fa-columns').addClass('fa-arrows-h'); + isSingleViewMode = true; + app_config.user.view_mode = 'single'; + } + }); +}); diff --git a/js/share.js b/js/share.js deleted file mode 100644 index 3dbbf0f..0000000 --- a/js/share.js +++ /dev/null @@ -1,1316 +0,0 @@ -/* global Ownnote, escapeHTML */ -window.Ownnote = {}; -window.Ownnote.Share = {}; - -(function ($, Ownnote) { - "use strict"; - - /** - * @typedef {Object} Ownnote.Share.Types.ShareInfo - * @property {Number} share_type - * @property {Number} permissions - * @property {Number} file_source optional - * @property {Number} item_source - * @property {String} token - * @property {String} share_with - * @property {String} share_with_displayname - * @property {String} mail_send - * @property {String} displayname_file_owner - * @property {String} displayname_owner - * @property {String} uid_owner - * @property {String} uid_file_owner - * @property {String} expiration optional - * @property {Number} stime - */ - - // copied and stripped out from the old core - var Share = { - SHARE_TYPE_USER: 0, - SHARE_TYPE_GROUP: 1, - SHARE_TYPE_LINK: 3, - SHARE_TYPE_EMAIL: 4, - SHARE_TYPE_REMOTE: 6, - - itemShares: [], - - /** - * Shares for the currently selected file. - * (for which the dropdown is open) - * - * Key is item type and value is an array or - * shares of the given item type. - */ - currentShares: {}, - - /** - * Whether the share dropdown is opened. - */ - droppedDown: false, - - /** - * - * @param path {String} path to the file/folder which should be shared - * @param shareType {Number} 0 = user; 1 = group; 3 = public link; 6 = federated cloud - * share - * @param shareWith {String} user / group id with which the file should be shared - * @param publicUpload {Boolean} allow public upload to a public shared folder - * @param password {String} password to protect public link Share with - * @param permissions {Number} 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 - * = all (default: 31, for public shares: 1) - * @param callback {Function} method to call back after a successful share creation - * @param errorCallback {Function} method to call back after a failed share creation - * - * @returns {*} - */ - share: function (noteid, shareType, shareWith, publicUpload, password, permissions, callback, errorCallback) { - - return $.ajax({ - url: OC.generateUrl('/apps/nextnote/') + 'api/v2/sharing/shares', - type: 'POST', - data: { - noteid: noteid, - shareType: shareType, - shareWith: shareWith, - publicUpload: publicUpload, - password: password, - permissions: permissions - }, - dataType: 'json' - }).done(function (result) { - if (result) { - var data = { - id: noteid - }; - if (callback) { - callback(data); - } - } - }).fail(function (xhr) { - var result = xhr.responseJSON; - if (_.isFunction(errorCallback)) { - errorCallback(result); - } else { - var msg = t('core', 'Error'); - if (result.ocs && result.ocs.meta.message) { - msg = result.ocs.meta.message; - } - OC.dialogs.alert(msg, t('core', 'Error while sharing')); - } - }); - }, - /** - * - * @param {Number} shareId - * @param {Function} callback - */ - unshare: function (shareId, shareType, shareWith, callback) { - var url = OC.generateUrl('/apps/nextnote/') + 'api/v2/sharing/shares/' + shareId; - url += '?' + $.param({ - 'shareType': shareType, - 'shareWith': shareWith - }); - $.ajax({ - url: url, - type: 'DELETE' - }).done(function () { - if (callback) { - callback(); - } - }).fail(function () { - OC.dialogs.alert(t('core', 'Error while unsharing'), t('core', 'Error')); - - }); - }, - /** - * - * @param {Number} shareId - * @param {Number} permissions - */ - setPermissions: function (shareId, shareType, shareWith, permissions) { - var url = OC.generateUrl('/apps/nextnote/') + 'api/v2/sharing/shares/' + shareId + '/permissions'; - $.ajax({ - url: url, - type: 'PUT', - data: { - shareType: shareType, - shareWith: shareWith, - permissions: permissions - } - }).fail(function () { - OC.dialogs.alert(t('core', 'Error while changing permissions'), - t('core', 'Error')); - }); - }, - /** - * - * @param {String} itemType - * @param {String} path - * @param {String} appendTo - * @param {String} link - * @param {Number} possiblePermissions - * @param {String} filename - */ - showDropDown: function (itemType, path, appendTo, link, possiblePermissions, filename) { - // This is a sync AJAX request on the main thread... - var data = this._loadShares(path); - var dropDownEl; - var self = this; - var html = ' -
- -
+ + + + + + + + + + + + + + +