Esempio n. 1
0
 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $certificateManager = $this->getMock('\\OCP\\ICertificateManager');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs(array($config, $certificateManager))->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new \OCA\Files_Sharing\API\Server2Server();
 }
Esempio n. 2
0
 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $clientService = $this->getMock('\\OCP\\Http\\Client\\IClientService');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs([$config, $clientService])->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new \OCA\Files_Sharing\API\Server2Server();
     $this->connection = \OC::$server->getDatabaseConnection();
 }
Esempio n. 3
0
 protected function setUp()
 {
     parent::setUp();
     \OC_Hook::clear('OC_Filesystem', 'setup');
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     \OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
     \OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
     $this->datadir = \OC_Config::getValue('datadirectory');
     $this->tmpDir = \OC_Helper::tmpFolder();
     \OC_Config::setValue('datadirectory', $this->tmpDir);
     $this->userBackend = new \OC_User_Dummy();
     \OC_User::useBackend($this->userBackend);
 }
Esempio n. 4
0
 protected function setUp()
 {
     parent::setUp();
     \OC_Hook::clear('OC_Filesystem', 'setup');
     $application = new \OCA\Files_Sharing\AppInfo\Application();
     $application->registerMountProviders();
     \OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
     \OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
     $this->datadir = \OC_Config::getValue('datadirectory');
     $this->tmpDir = \OC_Helper::tmpFolder();
     \OC_Config::setValue('datadirectory', $this->tmpDir);
     $this->userBackend = new \Test\Util\User\Dummy();
     \OC_User::useBackend($this->userBackend);
 }
Esempio n. 5
0
 protected function setUp()
 {
     parent::setUp();
     \OC_Hook::clear('OC_Filesystem', 'setup');
     $application = new \OCA\Files_Sharing\AppInfo\Application();
     $application->registerMountProviders();
     \OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
     \OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
     $config = \OC::$server->getConfig();
     $this->datadir = $config->getSystemValue('datadirectory');
     $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
     $config->setSystemValue('datadirectory', $this->tmpDir);
     $this->userBackend = new \Test\Util\User\Dummy();
     \OC_User::useBackend($this->userBackend);
 }
Esempio n. 6
0
 protected function setUp()
 {
     parent::setUp();
     \OC_User::clearBackends();
     \OC_User::useBackend('dummy');
     $this->user1 = $this->getUniqueID('user1_');
     $this->user2 = $this->getUniqueID('user2_');
     $this->user3 = $this->getUniqueID('user3_');
     $this->user4 = $this->getUniqueID('user4_');
     $this->user5 = $this->getUniqueID('user5_');
     $this->user6 = $this->getUniqueID('user6_');
     $this->groupAndUser = $this->getUniqueID('groupAndUser_');
     \OC::$server->getUserManager()->createUser($this->user1, 'pass');
     \OC::$server->getUserManager()->createUser($this->user2, 'pass');
     \OC::$server->getUserManager()->createUser($this->user3, 'pass');
     \OC::$server->getUserManager()->createUser($this->user4, 'pass');
     \OC::$server->getUserManager()->createUser($this->user5, 'pass');
     \OC::$server->getUserManager()->createUser($this->user6, 'pass');
     // no group
     \OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass');
     \OC_User::setUserId($this->user1);
     \OC_Group::clearBackends();
     \OC_Group::useBackend(new \Test\Util\Group\Dummy());
     $this->group1 = $this->getUniqueID('group1_');
     $this->group2 = $this->getUniqueID('group2_');
     \OC_Group::createGroup($this->group1);
     \OC_Group::createGroup($this->group2);
     \OC_Group::createGroup($this->groupAndUser);
     \OC_Group::addToGroup($this->user1, $this->group1);
     \OC_Group::addToGroup($this->user2, $this->group1);
     \OC_Group::addToGroup($this->user3, $this->group1);
     \OC_Group::addToGroup($this->user2, $this->group2);
     \OC_Group::addToGroup($this->user4, $this->group2);
     \OC_Group::addToGroup($this->user2, $this->groupAndUser);
     \OC_Group::addToGroup($this->user3, $this->groupAndUser);
     \OCP\Share::registerBackend('test', 'Test\\Share\\Backend');
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     $this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes');
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
     // 20 Minutes in the past, 20 minutes in the future.
     $now = time();
     $dateFormat = 'Y-m-d H:i:s';
     $this->dateInPast = date($dateFormat, $now - 20 * 60);
     $this->dateInFuture = date($dateFormat, $now + 20 * 60);
 }
Esempio n. 7
0
 public static function register()
 {
     \OCP\Share::registerBackend(App::SHARECALENDAR, '\\OCA\\CalendarPlus\\Share\\Backend\\Calendar');
     \OCP\Share::registerBackend(App::SHAREEVENT, '\\OCA\\CalendarPlus\\Share\\Backend\\Event');
     \OCP\Util::connectHook('OC_User', 'post_createUser', '\\OCA\\CalendarPlus\\Hooks', 'createUser');
     \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\\OCA\\CalendarPlus\\Hooks', 'deleteUser');
     if (\OC::$server->getAppManager()->isEnabledForUser('activity')) {
         \OCP\Util::connectHook('OCP\\Share', 'post_shared', '\\OCA\\CalendarPlus\\Hooks', 'share');
         \OCP\Util::connectHook('OCP\\Share', 'post_unshare', '\\OCA\\CalendarPlus\\Hooks', 'unshare');
     }
     //		\OCP\Util::connectHook('OCP\Share', 'share_internal_mail', 'OCA\Calendar\Hooks', 'shareInternalMail');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'addEvent', '\OCA\CalendarPlus\Repeat', 'generate');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'editEvent', '\OCA\CalendarPlus\Repeat', 'update');
     //	\OCP\Util::connectHook('\OCA\CalendarPlus', 'deleteEvent', '\OCA\CalendarPlus\Repeat', 'clean');
     //	\OCP\Util::connectHook('\OCA\CalendarPlus', 'moveEvent', '\OCA\CalendarPlus\Repeat', 'update');
     //\OCP\Util::connectHook('\OCA\CalendarPlus', 'deleteCalendar', '\OCA\CalendarPlus\Repeat', 'cleanCalendar');
 }
 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test\\Share\\Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $clientService = $this->getMock('\\OCP\\Http\\Client\\IClientService');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs([$config, $clientService])->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->share = $this->getMock('\\OCP\\Share\\IShare');
     $this->federatedShareProvider = $this->getMockBuilder('OCA\\FederatedFileSharing\\FederatedShareProvider')->disableOriginalConstructor()->getMock();
     $this->federatedShareProvider->expects($this->any())->method('isOutgoingServer2serverShareEnabled')->willReturn(true);
     $this->federatedShareProvider->expects($this->any())->method('isIncomingServer2serverShareEnabled')->willReturn(true);
     $this->federatedShareProvider->expects($this->any())->method('getShareById')->willReturn($this->share);
     $this->notifications = $this->getMockBuilder('OCA\\FederatedFileSharing\\Notifications')->disableOriginalConstructor()->getMock();
     $this->addressHandler = $this->getMockBuilder('OCA\\FederatedFileSharing\\AddressHandler')->disableOriginalConstructor()->getMock();
     $this->userManager = $this->getMock('OCP\\IUserManager');
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new RequestHandler($this->federatedShareProvider, \OC::$server->getDatabaseConnection(), \OC::$server->getShareManager(), \OC::$server->getRequest(), $this->notifications, $this->addressHandler, $this->userManager);
     $this->connection = \OC::$server->getDatabaseConnection();
 }
Esempio n. 9
0
 /**
  * Returns a list of calendars for a principal.
  *
  * Every project is an array with the following keys:
  *  * id, a unique id that will be used by other functions to modify the
  *	calendar. This can be the same as the uri or a database key.
  *  * uri, which the basename of the uri with which the calendar is
  *	accessed.
  *  * principalUri. The owner of the calendar. Almost always the same as
  *	principalUri passed to this method.
  *
  * Furthermore it can contain webdav properties in clark notation. A very
  * common one is '{DAV:}displayname'.
  *
  * @param string $principalUri
  * @return array
  */
 public function getCalendarsForUser($principalUri)
 {
     $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
     $calendars = array();
     foreach ($raw as $row) {
         $components = explode(',', $row['components']);
         if ($row['userid'] != OCP\USER::getUser()) {
             $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
         }
         $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components));
         foreach ($this->propertyMap as $xmlName => $dbName) {
             $calendar[$xmlName] = $row[$dbName];
         }
         $calendars[] = $calendar;
     }
     if (\OCP\App::isEnabled('contacts')) {
         \OCP\Share::registerBackend('addressbook', 'OCA\\Contacts\\Share\\Addressbook', 'contact');
         $app = new \OCA\Contacts\App(\OCP\User::getUser());
         $calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/contact_birthdays', '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT')));
     }
     return $calendars;
 }
Esempio n. 10
0
 * 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_sharing');
\OC::$CLASSPATH['OC_Share_Backend_File'] = 'files_sharing/lib/share/file.php';
\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') {
Esempio n. 11
0
\Sabre\VObject\Property::$classMap['ADR'] = '\\OC\\VObject\\CompoundProperty';
\Sabre\VObject\Property::$classMap['GEO'] = '\\OC\\VObject\\CompoundProperty';
\Sabre\VObject\Property::$classMap['ORG'] = '\\OC\\VObject\\CompoundProperty';
\OC::$server->getNavigationManager()->add(array('id' => 'contacts', 'order' => 10, 'href' => \OCP\Util::linkToRoute('contacts_index'), 'icon' => \OCP\Util::imagePath('contacts', 'contacts.svg'), 'name' => \OCP\Util::getL10N('contacts')->t('Contacts')));
$api = new API('contacts');
$api->connectHook('OC_User', 'post_createUser', '\\OCA\\Contacts\\Hooks', 'userCreated');
$api->connectHook('OC_User', 'post_deleteUser', '\\OCA\\Contacts\\Hooks', 'userDeleted');
$api->connectHook('OCA\\Contacts', 'pre_deleteAddressBook', '\\OCA\\Contacts\\Hooks', 'addressBookDeletion');
$api->connectHook('OCA\\Contacts', 'pre_deleteContact', '\\OCA\\Contacts\\Hooks', 'contactDeletion');
$api->connectHook('OCA\\Contacts', 'post_createContact', 'OCA\\Contacts\\Hooks', 'contactAdded');
$api->connectHook('OCA\\Contacts', 'post_updateContact', '\\OCA\\Contacts\\Hooks', 'contactUpdated');
$api->connectHook('OCA\\Contacts', 'scanCategories', '\\OCA\\Contacts\\Hooks', 'scanCategories');
$api->connectHook('OCA\\Contacts', 'indexProperties', '\\OCA\\Contacts\\Hooks', 'indexProperties');
$api->connectHook('OC_Calendar', 'getEvents', 'OCA\\Contacts\\Hooks', 'getBirthdayEvents');
$api->connectHook('OC_Calendar', 'getSources', 'OCA\\Contacts\\Hooks', 'getCalenderSources');
\OCP\Util::addscript('contacts', 'loader');
\OCP\Util::addscript('contacts', 'admin');
\OC_Search::registerProvider('OCA\\Contacts\\Search\\Provider');
//\OCP\Share::registerBackend('contact', 'OCA\Contacts\Share_Backend_Contact');
\OCP\Share::registerBackend('addressbook', 'OCA\\Contacts\\Share\\Addressbook', 'contact');
//\OCP\App::registerPersonal('contacts','personalsettings');
\OCP\App::registerAdmin('contacts', 'admin');
if (\OCP\User::isLoggedIn()) {
    $app = new App($api->getUserId());
    $addressBooks = $app->getAddressBooksForUser();
    foreach ($addressBooks as $addressBook) {
        if ($addressBook->isActive()) {
            \OCP\Contacts::registerAddressBook($addressBook->getSearchProvider());
        }
    }
}
Esempio n. 12
0
use OCA\ContactsPlus\App as ContactsApp;
use OCA\ContactsPlus\AddressbookProvider;
$app = new Application();
$c = $app->getContainer();
$contactsAppName = 'contactsplus';
// add an navigation entr
$navigationEntry = function () use($c) {
    return ['id' => $c->getAppName(), 'order' => 1, 'name' => $c->query('L10N')->t('Contacts+'), 'href' => $c->query('URLGenerator')->linkToRoute($c->getAppName() . '.page.index'), 'icon' => $c->query('URLGenerator')->imagePath($c->getAppName(), 'contacts.svg')];
};
$c->getServer()->getNavigationManager()->add($navigationEntry);
if (\OCP\User::isLoggedIn()) {
    \OCP\Util::addScript('contactsplus', 'search');
}
\OC::$server->getSearch()->registerProvider('OCA\\ContactsPlus\\Search\\Provider', array('app' => $contactsAppName));
\OCP\Share::registerBackend(ContactsApp::SHAREADDRESSBOOK, 'OCA\\ContactsPlus\\Share\\Backend\\Addressbook');
\OCP\Share::registerBackend(ContactsApp::SHARECONTACT, 'OCA\\ContactsPlus\\Share\\Backend\\Contact');
\OCP\Util::connectHook('OC_User', 'post_deleteUser', '\\OCA\\ContactsPlus\\Hooks', 'deleteUser');
if (\OCP\User::isLoggedIn() && !\OCP\App::isEnabled('contacts')) {
    $request = $c->query('Request');
    if (isset($request->server['REQUEST_URI'])) {
        $url = $request->server['REQUEST_URI'];
        if (preg_match('%index.php/apps/files(/.*)?%', $url) || preg_match('%index.php/s/(/.*)?%', $url)) {
            \OCP\Util::addscript($contactsAppName, 'loader');
        }
    }
}
if (\OCP\User::isLoggedIn()) {
    $cm = \OC::$server->getContactsManager();
    $cm->register(function () use($cm) {
        $myApp = new Application();
        $addressBooks = $myApp->getContainer()->query('AddressbookController')->getAddressBooksForCM();
 public function testKeepNonFileShares()
 {
     $this->loginAsUser($this->user1);
     \OCP\Share::registerBackend('test', 'Test\\Share\\Backend');
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), 'Failed asserting that user 1 successfully shared something with user 2.');
     $this->assertCount(1, $this->getShares());
     $this->job->run([]);
     $this->assertCount(1, $this->getShares(), 'Non-file shares kept');
 }
Esempio n. 14
0
 public function testShareTags()
 {
     $testTag = 'TestTag';
     \OCP\Share::registerBackend('test', 'Test\\Share\\Backend');
     $tagger = $this->tagMgr->load('test');
     $tagger->tagAs(1, $testTag);
     $otherUserId = $this->getUniqueID('user2_');
     \OC::$server->getUserManager()->createUser($otherUserId, 'pass');
     \OC_User::setUserId($otherUserId);
     $otherUserSession = $this->getMock('\\OCP\\IUserSession');
     $otherUserSession->expects($this->any())->method('getUser')->will($this->returnValue(new \OC\User\User($otherUserId, null)));
     $otherTagMgr = new \OC\TagManager($this->tagMapper, $otherUserSession);
     $otherTagger = $otherTagMgr->load('test');
     $this->assertFalse($otherTagger->hasTag($testTag));
     \OC_User::setUserId($this->user->getUID());
     \OCP\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
     \OC_User::setUserId($otherUserId);
     $otherTagger = $otherTagMgr->load('test', array(), true);
     // Update tags, load shared ones.
     $this->assertTrue($otherTagger->hasTag($testTag));
     $this->assertContains(1, $otherTagger->getIdsForTag($testTag));
 }
 /**
  * register search and share provider
  */
 public function registerProviders()
 {
     /* \OC_Search::registerProvider('\OCA\Calendar\SearchProvider'); */
     Share::registerBackend('calendar', '\\OCA\\Calendar\\Share\\Calendar');
     Share::registerBackend('event', '\\OCA\\Calendar\\Share\\Event');
 }
Esempio n. 16
0
 *
 * 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 OCA\TasksPlus\AppInfo;

use OCA\CalendarPlus\App as CalendarApp;
$app = new Application();
$c = $app->getContainer();
$taskAppName = $c->getAppName();
// add an navigation entry
$navigationEntry = function () use($c) {
    return ['id' => $c->getAppName(), 'order' => 1, 'name' => $c->query('L10N')->t('Tasks+'), 'href' => $c->query('URLGenerator')->linkToRoute($c->getAppName() . '.page.index'), 'icon' => $c->query('URLGenerator')->imagePath($c->getAppName(), 'tasksplus.svg')];
};
$c->getServer()->getNavigationManager()->add($navigationEntry);
if (\OC::$server->getAppManager()->isEnabledForUser('calendarplus')) {
    //upcoming version search for 8.2 perhaps patch https://github.com/owncloud/core/pull/17339/files
    \OC::$server->getSearch()->registerProvider('\\OCA\\TasksPlus\\Search\\Provider', array('app' => $taskAppName));
    \OCP\Share::registerBackend(CalendarApp::SHARETODO, '\\OCA\\TasksPlus\\Share\\Backend\\Vtodo');
}