当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Group类代码示例

本文整理汇总了PHP中OC_Group的典型用法代码示例。如果您正苦于以下问题:PHP OC_Group类的具体用法?PHP OC_Group怎么用?PHP OC_Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OC_Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkGroupRightsForPrincipal

 public static function checkGroupRightsForPrincipal($uid)
 {
     $appConfig = \OC::$server->getAppConfig();
     $isEnabled = $appConfig->getValue(self::$appname, 'enabled');
     $bEnabled = false;
     if ($isEnabled === 'yes') {
         $bEnabled = true;
     } else {
         if ($isEnabled === 'no') {
             $bEnabled = false;
         } else {
             if ($isEnabled !== 'no') {
                 $groups = json_decode($isEnabled);
                 if (is_array($groups)) {
                     foreach ($groups as $group) {
                         if (\OC_Group::inGroup($uid, $group)) {
                             $bEnabled = true;
                             break;
                         }
                     }
                 }
             }
         }
     }
     if ($bEnabled == false) {
         throw new \Sabre\DAV\Exception\Forbidden();
         return false;
     } else {
         return true;
     }
 }
开发者ID:ViToni,项目名称:contactsplus,代码行数:31,代码来源:app.php

示例2: tearDown

 protected function tearDown()
 {
     foreach ($this->users as $user) {
         \OC_User::deleteUser($user);
     }
     \OC_Group::deleteGroup('admin');
     parent::tearDown();
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:8,代码来源:testcase.php

示例3: checkSubAdminUser

	/**
	* Check if the user is a subadmin, send json error msg if not
	*/
	public static function checkSubAdminUser() {
		self::checkLoggedIn();
		self::verifyUser();
		if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
			$l = OC_L10N::get('lib');
			self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
			exit();
		}
	}
开发者ID:ryanshoover,项目名称:core,代码行数:12,代码来源:json.php

示例4: removeSharedFolder

/**
 * update script for the removal of the logical "Shared" folder, we create physical "Shared" folder and
 * update the users file_target so that it doesn't make any difference for the user
 * @note parameters are just for testing, please ignore them
 */
function removeSharedFolder($mkdirs = true, $chunkSize = 99)
{
    $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
    $result = $query->execute();
    $view = new \OC\Files\View('/');
    $users = array();
    $shares = array();
    //we need to set up user backends
    OC_User::useBackend(new OC_User_Database());
    OC_Group::useBackend(new OC_Group_Database());
    OC_App::loadApps(array('authentication'));
    //we need to set up user backends, otherwise creating the shares will fail with "because user does not exist"
    while ($row = $result->fetchRow()) {
        //collect all user shares
        if ((int) $row['share_type'] === 0 && ($row['item_type'] === 'file' || $row['item_type'] === 'folder')) {
            $users[] = $row['share_with'];
            $shares[$row['id']] = $row['file_target'];
        } else {
            if ((int) $row['share_type'] === 1 && ($row['item_type'] === 'file' || $row['item_type'] === 'folder')) {
                //collect all group shares
                $users = array_merge($users, \OC_group::usersInGroup($row['share_with']));
                $shares[$row['id']] = $row['file_target'];
            } else {
                if ((int) $row['share_type'] === 2) {
                    $shares[$row['id']] = $row['file_target'];
                }
            }
        }
    }
    $unique_users = array_unique($users);
    if (!empty($unique_users) && !empty($shares)) {
        // create folder Shared for each user
        if ($mkdirs) {
            foreach ($unique_users as $user) {
                \OC\Files\Filesystem::initMountPoints($user);
                if (!$view->file_exists('/' . $user . '/files/Shared')) {
                    $view->mkdir('/' . $user . '/files/Shared');
                }
            }
        }
        $chunkedShareList = array_chunk($shares, $chunkSize, true);
        $connection = \OC_DB::getConnection();
        foreach ($chunkedShareList as $subList) {
            $statement = "UPDATE `*PREFIX*share` SET `file_target` = CASE `id` ";
            //update share table
            $ids = implode(',', array_keys($subList));
            foreach ($subList as $id => $target) {
                $statement .= "WHEN " . $connection->quote($id, \PDO::PARAM_INT) . " THEN " . $connection->quote('/Shared' . $target, \PDO::PARAM_STR);
            }
            $statement .= ' END WHERE `id` IN (' . $ids . ')';
            $query = OCP\DB::prepare($statement);
            $query->execute(array());
        }
        // set config to keep the Shared folder as the default location for new shares
        \OCA\Files_Sharing\Helper::setShareFolder('/Shared');
    }
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:62,代码来源:update.php

示例5: __construct

 public function __construct(array $urlParams = array())
 {
     parent::__construct('User_Servervars2', $urlParams);
     $container = $this->getContainer();
     // Controller
     /*		$container->registerService('PageController', function ($c) {
     			return  new PageController();
     		});	*/
     $container->registerService('TokensFactory', function ($c) {
         return new TokensFactory($c->query('ServerContainer')->getAppConfig());
     });
     $container->registerService('Tokens', function ($c) {
         return $c->query('TokensFactory')->getTokens();
     });
     // Service
     $container->registerService('TokenService', function ($c) {
         return new TokenService($c->query('Tokens'));
     });
     $container->registerService('GroupManager', function ($c) {
         return \OC_Group::getManager();
         // return new \OC\Group\Manager(
         // 		$c->query('ServerContainer')->getUserManager()
         // 	);
     });
     // Service
     $container->registerService('UserAndGroupService', function ($c) {
         return new ProxyUserAndGroupService($c->query('ServerContainer')->getUserManager(), $c->query('GroupManager'), $c->query('GroupNamingServiceFactory')->getGroupNamingService(), $c->query('UserBackend'), $c->query('ServerContainer')->getConfig());
     });
     $container->registerService('GroupNamingServiceFactory', function ($c) {
         return new \OCA\User_Servervars2\Service\GroupNamingServiceFactory($c->query('ServerContainer')->getAppConfig());
     });
     // Interceptor
     $container->registerService('Interceptor', function ($c) {
         return new Interceptor($c->query('ServerContainer')->getAppConfig(), $c->query('Tokens'), $c->query('UserAndGroupService'));
     });
     // Hooks
     $container->registerService('ServerVarsHooks', function ($c) {
         return new ServerVarsHooks($c->query('TokenService'), $c->query('UserAndGroupService'), $c->query('ServerContainer')->getAppConfig());
     });
     // Backend
     $container->registerService('UserBackend', function ($c) {
         return new UserBackend($c->query('TokenService'), $c->query('ServerContainer')->getAppConfig());
     });
     // MetadataProvider
     // Backend
     $container->registerService('MetadataProvider', function ($c) {
         return new MetadataProvider($c->query('MetadataMapper'));
     });
     // Mappers
     $container->registerService('MetadataMapper', function ($c) {
         return new MetadataMapper();
     });
     // Mappers
     $container->registerService('SettingsController', function ($c) {
         return new SettingsController($c->query('Request'), $c->query('ServerContainer')->getAppConfig());
     });
 }
开发者ID:jeanaimar2,项目名称:user_servervars2,代码行数:57,代码来源:configapp.php

示例6: checkAdminUser

 /**
  * Check if the user is a admin, send json error msg if not
  */
 public static function checkAdminUser()
 {
     self::checkLoggedIn();
     if (!OC_Group::inGroup(OC_User::getUser(), 'admin')) {
         $l = new OC_L10N('core');
         self::error(array('data' => array('message' => $l->t('Authentication error'))));
         exit;
     }
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:12,代码来源:owncloud_lib_json.php

示例7: testGetApps

 public function testGetApps()
 {
     $user = $this->generateUsers();
     \OC_Group::addToGroup($user, 'admin');
     self::loginAsUser($user);
     $result = \OCA\provisioning_API\Apps::getApps(array());
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals(count(\OC_App::listAllApps()), count($data['apps']));
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:10,代码来源:appstest.php

示例8: tearDown

 public function tearDown()
 {
     OC_Mount_Config::$skipTest = false;
     \OC_User::deleteUser(self::TEST_USER2);
     \OC_User::deleteUser(self::TEST_USER1);
     \OC_Group::deleteGroup(self::TEST_GROUP1);
     \OC_Group::deleteGroup(self::TEST_GROUP2);
     @unlink($this->dataDir . '/mount.json');
     OCP\Config::setAppValue('files_external', 'user_mounting_backends', $this->oldAllowedBackends);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:10,代码来源:mountconfig.php

示例9: testSingleBackend

 function testSingleBackend()
 {
     OC_Group::useBackend(new OCA\user_ldap\GROUP_LDAP());
     $group_ldap = new OCA\user_ldap\GROUP_LDAP();
     $this->assertIsA(OC_Group::getGroups(), gettype(array()));
     $this->assertIsA($group_ldap->getGroups(), gettype(array()));
     $this->assertFalse(OC_Group::inGroup('john', 'dosers'), gettype(false));
     $this->assertFalse($group_ldap->inGroup('john', 'dosers'), gettype(false));
     //TODO: check also for expected true result. This backend won't be able to do any modifications, maybe use a dummy for this.
     $this->assertIsA(OC_Group::getUserGroups('john doe'), gettype(array()));
     $this->assertIsA($group_ldap->getUserGroups('john doe'), gettype(array()));
     $this->assertIsA(OC_Group::usersInGroup('campers'), gettype(array()));
     $this->assertIsA($group_ldap->usersInGroup('campers'), gettype(array()));
 }
开发者ID:ryanshoover,项目名称:core,代码行数:14,代码来源:group_ldap.php

示例10: OC_wordpress

 function OC_wordpress()
 {
     $this->db_conn = '';
     $this->params = array('wordpress_db_host', 'wordpress_db_user', 'wordpress_db_password', 'wordpress_db_name', 'wordpress_db_prefix', 'wordpress_url', 'wordpress_hash_salt', 'wordpress_have_to_be_logged', 'wordpress_global_group', 'wordpress_restrict_group', 'wordpress_add_button');
     $this->params = $this->getParams();
     if (OC_Appconfig::getValue('user_wordpress', 'clean_groups', 0) == 0 && isset($this->db)) {
         $res = $this->db->query('SELECT `blog_id`,`domain` FROM ' . $this->wordpress_db_prefix . 'blogs WHERE `deleted`=0 AND `spam`=0 ');
         if ($res->num_rows) {
             while ($blog = mysqli_fetch_assoc($res)) {
                 OC_Group::deleteGroup($blog['domain']);
             }
         }
         OC_Appconfig::setValue('user_wordpress', 'clean_groups', '1');
     }
     $this->connectdb();
 }
开发者ID:silvioheinze,项目名称:user_wordpress,代码行数:16,代码来源:wordpress.class.php

示例11: deleteGroup

 public static function deleteGroup($parameters)
 {
     // Check it exists
     if (!OC_Group::groupExists($parameters['groupid'])) {
         return 101;
     } else {
         if ($parameters['groupid'] == 'admin') {
             // Cannot delete admin group
             return 102;
         } else {
             if (OC_Group::deleteGroup($parameters['groupid'])) {
                 return 100;
             } else {
                 return 103;
             }
         }
     }
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:18,代码来源:groups.php

示例12: __construct

 public function __construct(array $urlParams = array())
 {
     parent::__construct('gatekeeper', $urlParams);
     $container = $this->getContainer();
     // Hooks
     $container->registerService('GateKeeperHooks', function ($c) {
         return new \OCA\GateKeeper\Hooks\GateKeeperHooks($c->query('GateKeeperService'), $c->query('Logger'));
     });
     // Service
     $container->registerService('GateKeeperService', function ($c) {
         return new \OCA\GateKeeper\Service\GateKeeperService($c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'mode'), $c->query('ServerContainer')->getSession(), $c->query('AccessObjectMapper'), $c->query('GroupManager'), GKHelper::isRemote(), $c->query('ServerContainer')->getAppConfig()->getValue('gatekeeper', 'refresh_delay'));
     });
     // Mapper
     $container->registerService('AccessObjectMapper', function ($c) {
         return new \OCA\GateKeeper\Db\AccessObjectMapper($c->query('ServerContainer')->getDb());
     });
     // groupManager
     $container->registerService('GroupManager', function ($c) {
         return \OC_Group::getManager();
     });
     // - logger -
     $container->registerService('Logger', function ($c) {
         return $c->query('ServerContainer')->getLogger();
     });
     $container->registerService('Interceptor', function ($c) {
         return new \OCA\GateKeeper\AppInfo\Interceptor($c->query('ServerContainer')->getUserSession(), \OC_User::isLoggedIn(), $c->query('GateKeeperService'), $c->query('L10N'), $c->query('DenyLogger'));
     });
     $container->registerService('L10N', function ($c) {
         return $c->query('ServerContainer')->getL10N($c->query('AppName'));
     });
     $container->registerService('SettingsController', function ($c) {
         return new \OCA\GateKeeper\Controller\SettingsController($c->query('Request'), $c->query('ServerContainer')->getAppConfig(), $c->query('AccessObjectMapper'), $c->query('GroupManager'));
     });
     $container->registerService('DenyLoggerFactory', function ($c) {
         return new \OCA\GateKeeper\Lib\DenyLoggerFactory($c->query('ServerContainer')->getAppConfig());
     });
     $container->registerService('DenyLogger', function ($c) {
         return $c->query('DenyLoggerFactory')->getInstance();
     });
 }
开发者ID:jeanaimar2,项目名称:gatekeeper,代码行数:40,代码来源:gatekeeperconfigapp.php

示例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);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:22,代码来源:ShareTest.php

示例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());
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:23,代码来源:groupstest.php

示例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));
 }
开发者ID:evanjt,项目名称:core,代码行数:23,代码来源:share.php


注:本文中的OC_Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。