當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。