本文整理汇总了PHP中OC_Group::createGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Group::createGroup方法的具体用法?PHP OC_Group::createGroup怎么用?PHP OC_Group::createGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Group
的用法示例。
在下文中一共展示了OC_Group::createGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user1 = uniqid('user1_');
$this->user2 = uniqid('user2_');
$this->user3 = uniqid('user3_');
$this->user4 = uniqid('user4_');
OC_User::createUser($this->user1, 'pass');
OC_User::createUser($this->user2, 'pass');
OC_User::createUser($this->user3, 'pass');
OC_User::createUser($this->user4, 'pass');
OC_User::setUserId($this->user1);
OC_Group::clearBackends();
OC_Group::useBackend(new OC_Group_Dummy());
$this->group1 = uniqid('group_');
$this->group2 = uniqid('group_');
OC_Group::createGroup($this->group1);
OC_Group::createGroup($this->group2);
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);
OCP\Share::registerBackend('test', 'Test_Share_Backend');
OC_Hook::clear('OCP\\Share');
OC::registerShareHooks();
$this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes');
OC_Appconfig::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);
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// enable resharing
\OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
// Sharing related hooks
\OCA\Encryption\Helper::registerShareHooks();
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// clear and register hooks
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create users
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
// create group and assign users
\OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
}
示例3: setUp
public function setUp()
{
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user1 = uniqid('user1_');
$this->user2 = uniqid('user2_');
$this->user3 = uniqid('user3_');
$this->user4 = uniqid('user4_');
OC_User::createUser($this->user1, 'pass');
OC_User::createUser($this->user2, 'pass');
OC_User::createUser($this->user3, 'pass');
OC_User::createUser($this->user4, 'pass');
OC_User::setUserId($this->user1);
OC_Group::clearBackends();
OC_Group::useBackend(new OC_Group_Dummy());
$this->group1 = uniqid('group_');
$this->group2 = uniqid('group_');
OC_Group::createGroup($this->group1);
OC_Group::createGroup($this->group2);
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);
OCP\Share::registerBackend('test', 'Test_Share_Backend');
OC_Hook::clear('OCP\\Share');
OC::registerShareHooks();
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// enable resharing
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
// register share hooks
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
// Sharing related hooks
\OCA\Encryption\Helper::registerShareHooks();
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// clear and register hooks
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Files\Share\Proxy());
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create users
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
// create group and assign users
\OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// create test user
self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1, true);
self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER2, true);
self::loginHelper(self::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
// create groups
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
// add user 1 to group1
\OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
self::setupHooks();
// create test user
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
// create groups
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
// add user 1 to group1
\OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
}
示例7: setUp
public function setUp()
{
\OC_User::createUser(self::TEST_USER1, self::TEST_USER1);
\OC_User::createUser(self::TEST_USER2, self::TEST_USER2);
\OC_Group::createGroup(self::TEST_GROUP1);
\OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1);
\OC_Group::createGroup(self::TEST_GROUP2);
\OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2);
\OC_User::setUserId(self::TEST_USER1);
$this->userHome = \OC_User::getHome(self::TEST_USER1);
mkdir($this->userHome);
$this->dataDir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
$this->oldAllowedBackends = OCP\Config::getAppValue('files_external', 'user_mounting_backends', '');
$this->allBackends = OC_Mount_Config::getBackends();
OCP\Config::setAppValue('files_external', 'user_mounting_backends', implode(',', array_keys($this->allBackends)));
OC_Mount_Config::$skipTest = true;
}
示例8: addGroup
/**
* creates a new group
*/
public static function addGroup($parameters)
{
// Validate name
$groupid = isset($_POST['groupid']) ? $_POST['groupid'] : '';
if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $groupid) || empty($groupid)) {
return 101;
}
// Check if it exists
if (OC_Group::groupExists($groupid)) {
return 102;
}
if (OC_Group::createGroup($groupid)) {
return 100;
} else {
return 103;
}
}
示例9: setUp
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);
}
示例10: testUnshareFromSelf
function testUnshareFromSelf()
{
\OC_Group::createGroup('testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
$fileinfo = $this->view->getFileInfo($this->filename);
$pathinfo = pathinfo($this->filename);
$duplicate = '/' . $pathinfo['filename'] . ' (2).' . $pathinfo['extension'];
$result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
$this->assertTrue($result);
$result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup', 31);
$this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
\OC\Files\Filesystem::unlink($this->filename);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
\OC\Files\Filesystem::unlink($duplicate);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
$this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
\OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::deleteGroup('testGroup');
}
示例11: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// enable resharing
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
// register share hooks
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
// clear and register hooks
\OC_FileProxy::register(new \OCA\Files\Share\Proxy());
// create users
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER4, true);
// create group and assign users
\OC_Group::createGroup(self::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER3, self::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER4, self::TEST_ENCRYPTION_SHARE_GROUP1);
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// clear and register hooks
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create test user
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
// create groups
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
\OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
// add user 1 to group1
\OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
}
示例13: testUnshareFromSelf
public function testUnshareFromSelf()
{
\OC_Group::createGroup('testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
$share1 = $this->share(\OCP\Share::SHARE_TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
$share2 = $this->share(\OCP\Share::SHARE_TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
\OC\Files\Filesystem::unlink($this->filename);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// both group share and user share should be gone
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
$this->shareManager->deleteShare($share1);
$this->shareManager->deleteShare($share2);
}
示例14: testGetSubAdminsOfGroup
public function testGetSubAdminsOfGroup()
{
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
\OC_SubAdmin::createSubAdmin($user2, $group1);
$result = \OCA\provisioning_api\Groups::getSubAdminsOfGroup(array('groupid' => $group1));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$data = $result->getData();
$this->assertEquals($user2, reset($data));
\OC_Group::deleteGroup($group1);
$user1 = $this->generateUsers();
self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$result = \OCA\provisioning_api\Groups::getSubAdminsOfGroup(array('groupid' => $this->getUniqueID()));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded());
$this->assertEquals(101, $result->getStatusCode());
}
示例15: testUnshareFromSelf
public function testUnshareFromSelf()
{
\OC_Group::createGroup('testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
$fileinfo = $this->view->getFileInfo($this->filename);
$result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
$this->assertTrue($result);
$result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup', 31);
$this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
\OC\Files\Filesystem::unlink($this->filename);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// both group share and user share should be gone
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
}