Ejemplo n.º 1
0
 /**
  * Test move to invalid name
  */
 function testRenameToInvalidName()
 {
     $dir = '/';
     $oldname = 'oldname';
     $newname = 'abc\\';
     $result = $this->files->rename($dir, $oldname, $newname);
     $this->assertFalse($result['success']);
     $this->assertEquals('File name contains at least one invalid character', $result['data']['message']);
     $this->assertEquals('invalidname', $result['data']['code']);
 }
Ejemplo n.º 2
0
 /**
  * Test move to a folder that doesn't exist any more
  */
 function testRenameToNonExistingFolder()
 {
     $dir = '/';
     $oldname = 'oldname';
     $newname = '/unexist/newname';
     $this->viewMock->expects($this->any())->method('file_exists')->with($this->anything())->will($this->returnValueMap(array(array('/oldname', true), array('/unexist', false))));
     $this->viewMock->expects($this->any())->method('getFileInfo')->will($this->returnValue(array('fileid' => 123, 'type' => 'dir', 'mimetype' => 'httpd/unix-directory', 'size' => 18, 'etag' => 'abcdef', 'directory' => '/unexist', 'name' => 'new_name')));
     $result = $this->files->rename($dir, $oldname, $newname);
     $this->assertFalse($result['success']);
     $this->assertEquals('targetnotfound', $result['data']['code']);
 }
Ejemplo n.º 3
0
    \OCP\Util::addScript('systemtags', 'systemtagsinfoview');
    \OCP\Util::addStyle('systemtags');
    \OCP\Util::addStyle('systemtags', 'systemtagsfilelist');
});
$activityManager = \OC::$server->getActivityManager();
$activityManager->registerExtension(function () {
    $application = new \OCP\AppFramework\App('systemtags');
    /** @var \OCA\SystemTags\Activity\Extension $extension */
    $extension = $application->getContainer()->query('OCA\\SystemTags\\Activity\\Extension');
    return $extension;
});
$managerListener = function (ManagerEvent $event) use($activityManager) {
    $application = new \OCP\AppFramework\App('systemtags');
    /** @var \OCA\SystemTags\Activity\Listener $listener */
    $listener = $application->getContainer()->query('OCA\\SystemTags\\Activity\\Listener');
    $listener->event($event);
};
$eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener);
$eventDispatcher->addListener(ManagerEvent::EVENT_DELETE, $managerListener);
$eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener);
$mapperListener = function (MapperEvent $event) use($activityManager) {
    $application = new \OCP\AppFramework\App('systemtags');
    /** @var \OCA\SystemTags\Activity\Listener $listener */
    $listener = $application->getContainer()->query('OCA\\SystemTags\\Activity\\Listener');
    $listener->mapperEvent($event);
};
$eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener);
$eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener);
$l = \OC::$server->getL10N('systemtags');
\OCA\Files\App::getNavigationManager()->add(array('id' => 'systemtagsfilter', 'appname' => 'systemtags', 'script' => 'list.php', 'order' => 9, 'name' => $l->t('Tags')));
Ejemplo n.º 4
0
Archivo: app.php Proyecto: kenwi/core
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC::$CLASSPATH['OC\\Files\\Storage\\StreamWrapper'] = 'files_external/lib/streamwrapper.php';
OC::$CLASSPATH['OC\\Files\\Storage\\FTP'] = 'files_external/lib/ftp.php';
OC::$CLASSPATH['OC\\Files\\Storage\\OwnCloud'] = 'files_external/lib/owncloud.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Google'] = 'files_external/lib/google.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Swift'] = 'files_external/lib/swift.php';
OC::$CLASSPATH['OC\\Files\\Storage\\SMB'] = 'files_external/lib/smb.php';
OC::$CLASSPATH['OC\\Files\\Storage\\AmazonS3'] = 'files_external/lib/amazons3.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Dropbox'] = 'files_external/lib/dropbox.php';
OC::$CLASSPATH['OC\\Files\\Storage\\SFTP'] = 'files_external/lib/sftp.php';
OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
OC::$CLASSPATH['OCA\\Files\\External\\Api'] = 'files_external/lib/api.php';
require_once __DIR__ . '/../3rdparty/autoload.php';
// register Application object singleton
\OC_Mount_Config::$app = new \OCA\Files_external\Appinfo\Application();
$appContainer = \OC_Mount_Config::$app->getContainer();
\OC_Mount_Config::$app->registerSettings();
$l = \OC::$server->getL10N('files_external');
\OCA\Files\App::getNavigationManager()->add(["id" => 'extstoragemounts', "appname" => 'files_external', "script" => 'list.php', "order" => 30, "name" => $l->t('External storage')]);
$mountProvider = $appContainer->query('OCA\\Files_External\\Config\\ConfigAdapter');
\OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
Ejemplo n.º 5
0
    }
    header('Location: ' . OCP\Util::linkTo('files', 'index.php') . $hash);
    exit;
}
$user = OC_User::getUser();
$config = \OC::$server->getConfig();
// mostly for the home storage's free space
$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
$storageInfo = OC_Helper::getStorageInfo('/', $dirInfo);
$nav = new OCP\Template('files', 'appnavigation', '');
function sortNavigationItems($item1, $item2)
{
    return $item1['order'] - $item2['order'];
}
\OCA\Files\App::getNavigationManager()->add(array('id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => $l->t('Favorites')));
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
usort($navItems, 'sortNavigationItems');
$nav->assign('navigationItems', $navItems);
$contentItems = array();
function renderScript($appName, $scriptName)
{
    $content = '';
    $appPath = OC_App::getAppPath($appName);
    $scriptPath = $appPath . '/' . $scriptName;
    if (file_exists($scriptPath)) {
        // TODO: sanitize path / script name ?
        ob_start();
        include $scriptPath;
        $content = ob_get_contents();
        @ob_end_clean();
    }
Ejemplo n.º 6
0
Archivo: app.php Proyecto: hyb148/core
<?php

/**
 * @author Bart Visscher <*****@*****.**>
 * @author Björn Schießle <*****@*****.**>
 * @author Christopher Schäpers <*****@*****.**>
 * @author Florin Peter <*****@*****.**>
 * @author Robin Appelman <*****@*****.**>
 * @author Vincent Petry <*****@*****.**>
 *
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
$l = \OC::$server->getL10N('files_trashbin');
// register hooks
\OCA\Files_Trashbin\Trashbin::registerHooks();
\OCA\Files\App::getNavigationManager()->add(array("id" => 'trashbin', "appname" => 'files_trashbin', "script" => 'list.php', "order" => 50, "name" => $l->t('Deleted files')));
Ejemplo n.º 7
0
<?php

\OCP\App::registerAdmin('files', 'admin');
\OC::$server->getNavigationManager()->add(function () {
    $l = \OC::$server->getL10N('files');
    return ['id' => 'files_index', 'order' => 0, 'href' => \OCP\Util::linkTo('files', 'index.php'), 'icon' => \OCP\Util::imagePath('core', 'places/files.svg'), 'name' => $l->t('Files')];
});
\OC::$server->getSearch()->registerProvider('OC\\Search\\Provider\\File', array('apps' => array('files')));
$templateManager = \OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('text/html', 'core/templates/filetemplates/template.html');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
\OCA\Files\App::getNavigationManager()->add(function () {
    $l = \OC::$server->getL10N('files');
    return ['id' => 'files', 'appname' => 'files', 'script' => 'list.php', 'order' => 0, 'name' => $l->t('All files')];
});
\OC::$server->getActivityManager()->registerExtension(function () {
    return new \OCA\Files\Activity(\OC::$server->query('L10NFactory'), \OC::$server->getURLGenerator(), \OC::$server->getActivityManager(), new \OCA\Files\ActivityHelper(\OC::$server->getTagManager()), \OC::$server->getConfig());
});
Ejemplo n.º 8
0
\OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'files_sharing/lib/share/folder.php';
\OC::$CLASSPATH['OC\\Files\\Storage\\Shared'] = 'files_sharing/lib/sharedstorage.php';
$application = new \OCA\Files_Sharing\AppInfo\Application();
$application->registerMountProviders();
\OCA\Files_Sharing\Helper::registerHooks();
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
\OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
$eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener('OCA\\Files::loadAdditionalScripts', function () {
    \OCP\Util::addScript('files_sharing', 'share');
    \OCP\Util::addScript('files_sharing', 'sharetabview');
    if (\OC::$server->getConfig()->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes') {
        \OCP\Util::addScript('files_sharing', 'external');
    }
    \OCP\Util::addStyle('files_sharing', 'sharetabview');
});
// \OCP\Util::addStyle('files_sharing', 'sharetabview');
\OC::$server->getActivityManager()->registerExtension(function () {
    return new \OCA\Files_Sharing\Activity(\OC::$server->query('L10NFactory'), \OC::$server->getURLGenerator(), \OC::$server->getActivityManager());
});
$config = \OC::$server->getConfig();
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
    \OCA\Files\App::getNavigationManager()->add(array("id" => 'sharingin', "appname" => 'files_sharing', "script" => 'list.php', "order" => 10, "name" => $l->t('Shared with you')));
    if (\OCP\Util::isSharingDisabledForUser() === false) {
        \OCA\Files\App::getNavigationManager()->add(array("id" => 'sharingout', "appname" => 'files_sharing', "script" => 'list.php', "order" => 15, "name" => $l->t('Shared with others')));
        // Check if sharing by link is enabled
        if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
            \OCA\Files\App::getNavigationManager()->add(array("id" => 'sharinglinks', "appname" => 'files_sharing', "script" => 'list.php', "order" => 20, "name" => $l->t('Shared by link')));
        }
    }
}
Ejemplo n.º 9
0
 /**
  * @NoCSRFRequired
  * @NoAdminRequired
  *
  * @param string $dir
  * @param string $view
  * @return TemplateResponse
  * @throws \OCP\Files\NotFoundException
  */
 public function index($dir = '', $view = '')
 {
     $nav = new \OCP\Template('files', 'appnavigation', '');
     // Load the files we need
     \OCP\Util::addStyle('files', 'files');
     \OCP\Util::addStyle('files', 'upload');
     \OCP\Util::addStyle('files', 'mobile');
     \OCP\Util::addscript('files', 'app');
     \OCP\Util::addscript('files', 'file-upload');
     \OCP\Util::addscript('files', 'newfilemenu');
     \OCP\Util::addscript('files', 'jquery.iframe-transport');
     \OCP\Util::addscript('files', 'jquery.fileupload');
     \OCP\Util::addscript('files', 'jquery-visibility');
     \OCP\Util::addscript('files', 'fileinfomodel');
     \OCP\Util::addscript('files', 'filesummary');
     \OCP\Util::addscript('files', 'breadcrumb');
     \OCP\Util::addscript('files', 'filelist');
     \OCP\Util::addscript('files', 'search');
     \OCP\Util::addScript('files', 'favoritesfilelist');
     \OCP\Util::addScript('files', 'tagsplugin');
     \OCP\Util::addScript('files', 'favoritesplugin');
     \OCP\Util::addScript('files', 'detailfileinfoview');
     \OCP\Util::addScript('files', 'detailtabview');
     \OCP\Util::addScript('files', 'mainfileinfodetailview');
     \OCP\Util::addScript('files', 'detailsview');
     \OCP\Util::addStyle('files', 'detailsView');
     \OC_Util::addVendorScript('core', 'handlebars/handlebars');
     \OCP\Util::addscript('files', 'fileactions');
     \OCP\Util::addscript('files', 'fileactionsmenu');
     \OCP\Util::addscript('files', 'files');
     \OCP\Util::addscript('files', 'keyboardshortcuts');
     \OCP\Util::addscript('files', 'navigation');
     // if IE8 and "?dir=path&view=someview" was specified, reformat the URL to use a hash like "#?dir=path&view=someview"
     $isIE8 = $this->request->isUserAgent([Request::USER_AGENT_IE_8]);
     if ($isIE8 && ($dir !== '' || $view !== '')) {
         $dir = !empty($dir) ? $dir : '/';
         $view = !empty($view) ? $view : 'files';
         $hash = '#?dir=' . \OCP\Util::encodePath($dir);
         if ($view !== 'files') {
             $hash .= '&view=' . urlencode($view);
         }
         return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index') . $hash);
     }
     // mostly for the home storage's free space
     // FIXME: Make non static
     $storageInfo = $this->getStorageInfo();
     \OCA\Files\App::getNavigationManager()->add(['id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => $this->l10n->t('Favorites')]);
     $navItems = \OCA\Files\App::getNavigationManager()->getAll();
     usort($navItems, function ($item1, $item2) {
         return $item1['order'] - $item2['order'];
     });
     $nav->assign('navigationItems', $navItems);
     $contentItems = [];
     // render the container content for every navigation item
     foreach ($navItems as $item) {
         $content = '';
         if (isset($item['script'])) {
             $content = $this->renderScript($item['appname'], $item['script']);
         }
         $contentItem = [];
         $contentItem['id'] = $item['id'];
         $contentItem['content'] = $content;
         $contentItems[] = $contentItem;
     }
     $this->eventDispatcher->dispatch('OCA\\Files::loadAdditionalScripts');
     $params = [];
     $params['usedSpacePercent'] = (int) $storageInfo['relative'];
     $params['owner'] = $storageInfo['owner'];
     $params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
     $params['isPublic'] = false;
     $params['mailNotificationEnabled'] = $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no');
     $params['mailPublicNotificationEnabled'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no');
     $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
     $params['appNavigation'] = $nav;
     $params['appContents'] = $contentItems;
     $this->navigationManager->setActiveEntry('files_index');
     $response = new TemplateResponse($this->appName, 'index', $params);
     $policy = new ContentSecurityPolicy();
     $policy->addAllowedFrameDomain('\'self\'');
     $response->setContentSecurityPolicy($policy);
     return $response;
 }
Ejemplo n.º 10
0
<?php

/**
 * ownCloud - filefilter
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author sunny <*****@*****.**>
 * @copyright sunny 2015
 */
namespace OCA\Filefilter\AppInfo;

$l = \OC::$server->getL10N('filefilter');
\OCA\Files\App::getNavigationManager()->add(array("id" => 'pictures', "appname" => 'filefilter', "script" => 'list.php', "order" => 50, "name" => $l->t('Pictures')));
\OCA\Files\App::getNavigationManager()->add(array("id" => 'documents', "appname" => 'filefilter', "script" => 'list.php', "order" => 51, "name" => $l->t('Documents')));
\OCA\Files\App::getNavigationManager()->add(array('id' => 'videos', 'appname' => 'filefilter', 'script' => 'list.php', "order" => 52, 'name' => $l->t('Videos')));
\OCA\Files\App::getNavigationManager()->add(array('id' => 'audios', 'appname' => 'filefilter', 'script' => 'list.php', "order" => 53, 'name' => $l->t('Audios')));
\OCA\Files\App::getNavigationManager()->add(array('id' => 'others', 'appname' => 'filefilter', 'script' => 'list.php', "order" => 54, 'name' => $l->t('Others')));
Ejemplo n.º 11
0
<?php

$l = OC_L10N::get('files');
OCP\App::registerAdmin('files', 'admin');
OCP\App::addNavigationEntry(array("id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo("files", "index.php"), "icon" => OCP\Util::imagePath("core", "places/files.svg"), "name" => $l->t("Files")));
\OC::$server->getSearch()->registerProvider('OC\\Search\\Provider\\File');
$templateManager = OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('text/html', 'core/templates/filetemplates/template.html');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
\OCA\Files\App::getNavigationManager()->add(array("id" => 'files', "appname" => 'files', "script" => 'list.php', "order" => 0, "name" => $l->t('All files')));