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


PHP OC_SubAdmin类代码示例

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


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

示例1: getUsers

 /**
  * returns a list of users
  *
  * @return OC_OCS_Result
  */
 public function getUsers()
 {
     $search = !empty($_GET['search']) ? $_GET['search'] : '';
     $limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
     $offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
     // Check if user is logged in
     $user = $this->userSession->getUser();
     if ($user === null) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
     }
     // Admin? Or SubAdmin?
     if ($this->groupManager->isAdmin($user->getUID())) {
         $users = $this->userManager->search($search, $limit, $offset);
     } else {
         if (\OC_SubAdmin::isSubAdmin($user->getUID())) {
             $subAdminOfGroups = \OC_SubAdmin::getSubAdminsGroups($user->getUID());
             if ($offset === null) {
                 $offset = 0;
             }
             $users = [];
             foreach ($subAdminOfGroups as $group) {
                 $users = array_merge($users, $this->groupManager->displayNamesInGroup($group, $search));
             }
             $users = array_slice($users, $offset, $limit);
         } else {
             return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
         }
     }
     $users = array_keys($users);
     return new OC_OCS_Result(['users' => $users]);
 }
开发者ID:jincreator,项目名称:core,代码行数:36,代码来源:users.php

示例2: checkSubAdminUser

 /**
  * Check if the user is a subadmin, send json error msg if not
  */
 public static function checkSubAdminUser()
 {
     if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
         $l = OC_L10N::get('lib');
         self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
         exit;
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:json.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: getGroup

 /**
  * returns an array of users in the group specified
  */
 public static function getGroup($parameters)
 {
     // Check the group exists
     if (!OC_Group::groupExists($parameters['groupid'])) {
         return new OC_OCS_Result(null, \OC_API::RESPOND_NOT_FOUND, 'The requested group could not be found');
     }
     // Check subadmin has access to this group
     if (\OC_User::isAdminUser(\OC_User::getUser()) || in_array($parameters['groupid'], \OC_SubAdmin::getSubAdminsGroups(\OC_User::getUser()))) {
         return new OC_OCS_Result(array('users' => OC_Group::usersInGroup($parameters['groupid'])));
     } else {
         return new OC_OCS_Result(null, \OC_API::RESPOND_UNAUTHORISED, 'User does not have access to specified group');
     }
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:16,代码来源:groups.php

示例5: getAdministeredGroups

 private function getAdministeredGroups()
 {
     $this->requireLogin();
     if (class_exists('\\OC_SubAdmin', true)) {
         return \OC_SubAdmin::getSubAdminsGroups($this->getUserId());
     }
     // Nextcloud 9
     $subadmin = new \OC\SubAdmin(\OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getDatabaseConnection());
     $ocgroups = $subadmin->getSubAdminsGroups($this->user);
     $groups = array();
     foreach ($ocgroups as $ocgroup) {
         $groups[] = $ocgroup->getGID();
     }
     return $groups;
 }
开发者ID:strukturag,项目名称:nextcloud-spreedme,代码行数:15,代码来源:user.php

示例6: getGroup

 /**
  * returns an array of users in the group specified
  */
 public function getGroup($parameters)
 {
     // Check if user is logged in
     $user = $this->userSession->getUser();
     if ($user === null) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
     }
     // Check the group exists
     if (!$this->groupManager->groupExists($parameters['groupid'])) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested group could not be found');
     }
     // Check subadmin has access to this group
     if ($this->groupManager->isAdmin($user->getUID()) || in_array($parameters['groupid'], \OC_SubAdmin::getSubAdminsGroups($user->getUID()))) {
         $users = $this->groupManager->get($parameters['groupid'])->getUsers();
         $users = array_map(function ($user) {
             return $user->getUID();
         }, $users);
         $users = array_values($users);
         return new OC_OCS_Result(['users' => $users]);
     } else {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'User does not have access to specified group');
     }
 }
开发者ID:rosarion,项目名称:core,代码行数:26,代码来源:groups.php

示例7: 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

示例8: isAllowedToDeleteCalendar

 /**
  * @param array $calendar
  * @param string $userId
  * @return boolean
  */
 private static function isAllowedToDeleteCalendar($calendar)
 {
     $userId = OCP\User::getUser();
     //in case it is called by command line or cron
     if ($userId == '') {
         return true;
     }
     if ($calendar['userid'] === $userId) {
         return true;
     }
     if (OC_User::isAdminUser($userId)) {
         return true;
     }
     if (OC_SubAdmin::isUserAccessible($userId, $calendar['userid'])) {
         return true;
     }
     return false;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:23,代码来源:calendar.php

示例9: isset

<?php

// Check if we are a user
OCP\JSON::callCheck();
OC_JSON::checkLoggedIn();
// Manually load apps to ensure hooks work correctly (workaround for issue 1503)
OC_APP::loadApps();
$username = isset($_POST['username']) ? $_POST['username'] : OC_User::getUser();
$password = isset($_POST['password']) ? $_POST['password'] : null;
$oldPassword = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : '';
$recoveryPassword = isset($_POST['recoveryPassword']) ? $_POST['recoveryPassword'] : null;
$userstatus = null;
if (OC_User::isAdminUser(OC_User::getUser())) {
    $userstatus = 'admin';
}
if (OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
    $userstatus = 'subadmin';
}
if (OC_User::getUser() === $username && OC_User::checkPassword($username, $oldPassword)) {
    $userstatus = 'user';
}
if (is_null($userstatus)) {
    OC_JSON::error(array('data' => array('message' => 'Authentication error')));
    exit;
}
if (\OCP\App::isEnabled('files_encryption') && $userstatus !== 'user') {
    //handle the recovery case
    $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $username);
    $recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');
    $validRecoveryPassword = false;
    $recoveryPasswordSupported = false;
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:changepassword.php

示例10: array

    $pattern = '';
}
$users = array();
$userManager = \OC_User::getManager();
if (OC_User::isAdminUser(OC_User::getUser())) {
    if ($gid !== false) {
        $batch = OC_Group::displayNamesInGroup($gid, $pattern, $limit, $offset);
    } else {
        $batch = OC_User::getDisplayNames($pattern, $limit, $offset);
    }
    foreach ($batch as $uid => $displayname) {
        $user = $userManager->get($uid);
        $users[] = array('name' => $uid, 'displayname' => $displayname, 'groups' => join(', ', OC_Group::getUserGroups($uid)), 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($uid)), 'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'), 'storageLocation' => $user->getHome(), 'lastLogin' => $user->getLastLogin());
    }
} else {
    $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
    if ($gid !== false && in_array($gid, $groups)) {
        $groups = array($gid);
    } elseif ($gid !== false) {
        //don't you try to investigate loops you must not know about
        $groups = array();
    }
    $batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset);
    foreach ($batch as $uid) {
        $user = $userManager->get($uid);
        // Only add the groups, this user is a subadmin of
        $userGroups = array_intersect(OC_Group::getUserGroups($uid), OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()));
        $users[] = array('name' => $uid, 'displayname' => $user->getDisplayName(), 'groups' => join(', ', $userGroups), 'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'), 'storageLocation' => $user->getHome(), 'lastLogin' => $user->getLastLogin());
    }
}
OC_JSON::success(array('data' => $users));
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:userlist.php

示例11:

<?php

// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$username = $_POST["username"];
$group = OC_Util::sanitizeHTML($_POST["group"]);
// Toggle group
if (OC_SubAdmin::isSubAdminofGroup($username, $group)) {
    OC_SubAdmin::deleteSubAdmin($username, $group);
} else {
    OC_SubAdmin::createSubAdmin($username, $group);
}
OC_JSON::success();
开发者ID:noci2012,项目名称:owncloud,代码行数:15,代码来源:togglesubadmins.php

示例12: array

    if (isset($_POST["groups"])) {
        $groups = $_POST["groups"];
    }
} else {
    if (isset($_POST["groups"])) {
        $groups = array();
        foreach ($_POST["groups"] as $group) {
            if (OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group)) {
                $groups[] = $group;
            }
        }
        if (count($groups) == 0) {
            $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
        }
    } else {
        $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
    }
}
$username = $_POST["username"];
$password = $_POST["password"];
// Does the group exist?
if (in_array($username, OC_User::getUsers())) {
    OC_JSON::error(array("data" => array("message" => "User already exists")));
    exit;
}
// Return Success story
try {
    OC_User::createUser($username, $password);
    foreach ($groups as $i) {
        if (!OC_Group::groupExists($i)) {
            OC_Group::createGroup($i);
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:createuser.php

示例13: isset

 * 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/>
 *
 */
OC_JSON::checkSubAdminUser();
OCP\JSON::callCheck();
$username = isset($_POST["username"]) ? (string) $_POST["username"] : '';
if ($username === '' && !OC_User::isAdminUser(OC_User::getUser()) || !OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
    $l = \OC::$server->getL10N('core');
    OC_JSON::error(array('data' => array('message' => $l->t('Authentication error'))));
    exit;
}
//make sure the quota is in the expected format
$quota = (string) $_POST["quota"];
if ($quota !== 'none' and $quota !== 'default') {
    $quota = OC_Helper::computerFileSize($quota);
    $quota = OC_Helper::humanFileSize($quota);
}
// Return Success story
if ($username) {
    \OC::$server->getConfig()->setUserValue($username, 'files', 'quota', $quota);
} else {
    //set the default quota when no username is specified
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:setquota.php

示例14: checkSubAdminUser

 /**
  * Check if the user is a subadmin, redirects to home if not
  *
  * @return null|boolean $groups where the current user is subadmin
  */
 public static function checkSubAdminUser()
 {
     OC_Util::checkLoggedIn();
     if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
         header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php'));
         exit;
     }
     return true;
 }
开发者ID:pinoniq,项目名称:core,代码行数:14,代码来源:util.php

示例15: array

<?php

OC_JSON::checkSubAdminUser();
OCP\JSON::callCheck();
$success = true;
$username = $_POST["username"];
$group = $_POST["group"];
if ($username == OC_User::getUser() && $group == "admin" && OC_User::isAdminUser($username)) {
    $l = OC_L10N::get('core');
    OC_JSON::error(array('data' => array('message' => $l->t('Admins can\'t remove themself from the admin group'))));
    exit;
}
if (!OC_User::isAdminUser(OC_User::getUser()) && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) {
    $l = OC_L10N::get('core');
    OC_JSON::error(array('data' => array('message' => $l->t('Authentication error'))));
    exit;
}
if (!OC_Group::groupExists($group)) {
    OC_Group::createGroup($group);
}
$l = OC_L10N::get('settings');
$error = $l->t("Unable to add user to group %s", $group);
$action = "add";
// Toggle group
if (OC_Group::inGroup($username, $group)) {
    $action = "remove";
    $error = $l->t("Unable to remove user from group %s", $group);
    $success = OC_Group::removeFromGroup($username, $group);
    $usersInGroup = OC_Group::usersInGroup($group);
    if (count($usersInGroup) == 0) {
        OC_Group::deleteGroup($group);
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:togglegroups.php


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