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


PHP OC_SubAdmin::getSubAdminsGroups方法代码示例

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


在下文中一共展示了OC_SubAdmin::getSubAdminsGroups方法的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: 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

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

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

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

示例6: create

 /**
  * @NoAdminRequired
  *
  * @param string $username
  * @param string $password
  * @param array $groups
  * @param string $email
  * @return DataResponse
  *
  * TODO: Tidy up and write unit tests - code is mainly static method calls
  */
 public function create($username, $password, array $groups = array(), $email = '')
 {
     if ($email !== '' && !$this->mail->validateAddress($email)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mail address')), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     // TODO FIXME get rid of the static calls to OC_Subadmin
     if (!$this->isAdmin) {
         if (!empty($groups)) {
             foreach ($groups as $key => $group) {
                 if (!\OC_SubAdmin::isGroupAccessible($this->userSession->getUser()->getUID(), $group)) {
                     unset($groups[$key]);
                 }
             }
         }
         if (empty($groups)) {
             $groups = \OC_SubAdmin::getSubAdminsGroups($this->userSession->getUser()->getUID());
         }
     }
     try {
         $user = $this->userManager->createUser($username, $password);
     } catch (\Exception $exception) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
     }
     if ($user instanceof User) {
         if ($groups !== null) {
             foreach ($groups as $groupName) {
                 $group = $this->groupManager->get($groupName);
                 if (empty($group)) {
                     $group = $this->groupManager->createGroup($groupName);
                 }
                 $group->addUser($user);
             }
         }
         /**
          * Send new user mail only if a mail is set
          */
         if ($email !== '') {
             $this->config->setUserValue($username, 'settings', 'email', $email);
             // data for the mail template
             $mailData = array('username' => $username, 'url' => $this->urlGenerator->getAbsoluteURL('/'));
             $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
             $mailContent = $mail->render();
             $mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
             $plainTextMailContent = $mail->render();
             $subject = $this->l10n->t('Your %s account was created', [$this->defaults->getName()]);
             try {
                 $this->mail->send($email, $username, $subject, $mailContent, $this->fromMailAddress, $this->defaults->getName(), 1, $plainTextMailContent);
             } catch (\Exception $e) {
                 $this->log->error("Can't send new user mail to {$email}: " . $e->getMessage(), array('app' => 'settings'));
             }
         }
         // fetch users groups
         $userGroups = $this->groupManager->getUserGroupIds($user);
         return new DataResponse($this->formatUserForIndex($user, $userGroups), Http::STATUS_CREATED);
     }
     return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:68,代码来源:userscontroller.php

示例7: formatUserForIndex

 /**
  * @param IUser $user
  * @param array $userGroups
  * @return array
  */
 private function formatUserForIndex(IUser $user, array $userGroups = null)
 {
     // TODO: eliminate this encryption specific code below and somehow
     // hook in additional user info from other apps
     // recovery isn't possible if admin or user has it disabled and encryption
     // is enabled - so we eliminate the else paths in the conditional tree
     // below
     $restorePossible = false;
     if ($this->isEncryptionAppEnabled) {
         if ($this->isRestoreEnabled) {
             // check for the users recovery setting
             $recoveryMode = $this->config->getUserValue($user->getUID(), 'encryption', 'recoveryEnabled', '0');
             // method call inside empty is possible with PHP 5.5+
             $recoveryModeEnabled = !empty($recoveryMode);
             if ($recoveryModeEnabled) {
                 // user also has recovery mode enabled
                 $restorePossible = true;
             }
         }
     } else {
         // recovery is possible if encryption is disabled (plain files are
         // available)
         $restorePossible = true;
     }
     return ['name' => $user->getUID(), 'displayname' => $user->getDisplayName(), 'groups' => empty($userGroups) ? $this->groupManager->getUserGroupIds($user) : $userGroups, 'subadmin' => \OC_SubAdmin::getSubAdminsGroups($user->getUID()), 'quota' => $this->config->getUserValue($user->getUID(), 'files', 'quota', 'default'), 'storageLocation' => $user->getHome(), 'lastLogin' => $user->getLastLogin() * 1000, 'backend' => $user->getBackendClassName(), 'email' => $this->config->getUserValue($user->getUID(), 'settings', 'email', ''), 'isRestoreDisabled' => !$restorePossible];
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:31,代码来源:userscontroller.php

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

示例9: array

OC_Util::addStyle('settings', 'settings');
OC_App::setActiveNavigationEntry('core_users');
$users = array();
$groups = array();
$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin') ? true : false;
if ($isadmin) {
    $accessiblegroups = OC_Group::getGroups();
    $accessibleusers = OC_User::getUsers('', 30);
    $subadmins = OC_SubAdmin::getAllSubAdmins();
} else {
    $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
    $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
    $subadmins = false;
}
foreach ($accessibleusers as $i) {
    $users[] = array("name" => $i, "groups" => join(", ", OC_Group::getUserGroups($i)), 'quota' => OC_Preferences::getValue($i, 'files', 'quota', 'default'), 'subadmin' => implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
}
foreach ($accessiblegroups as $i) {
    // Do some more work here soon
    $groups[] = array("name" => $i);
}
$quotaPreset = OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB');
$quotaPreset = explode(',', $quotaPreset);
foreach ($quotaPreset as &$preset) {
    $preset = trim($preset);
}
$defaultQuota = OC_Appconfig::getValue('files', 'default_quota', 'none');
$tmpl = new OC_Template("settings", "users", "user");
$tmpl->assign("users", $users);
$tmpl->assign("groups", $groups);
$tmpl->assign('isadmin', (int) $isadmin);
开发者ID:ryanshoover,项目名称:core,代码行数:31,代码来源:users.php

示例10: getGroups

 /**
  * returns the available groups
  * @param string $search a search string
  * @return \OC\Group\Group[]
  */
 private function getGroups($search = '')
 {
     if ($this->isAdmin) {
         return $this->groupManager->search($search);
     } else {
         // FIXME: Remove static method call
         $groupIds = \OC_SubAdmin::getSubAdminsGroups($this->user);
         /* \OC_SubAdmin::getSubAdminsGroups() returns an array of GIDs, but this
          * method is expected to return an array with the GIDs as keys and group objects as
          * values, so we need to convert this information.
          */
         $groups = array();
         foreach ($groupIds as $gid) {
             $group = $this->groupManager->get($gid);
             if (!is_null($group)) {
                 $groups[$gid] = $group;
             }
         }
         return $groups;
     }
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:26,代码来源:metadata.php

示例11: foreach

<?php

OC_JSON::callCheck();
OC_JSON::checkSubAdminUser();
$userCount = 0;
$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
if (!OC_User::isAdminUser($currentUser)) {
    $groups = OC_SubAdmin::getSubAdminsGroups($currentUser);
    foreach ($groups as $group) {
        $userCount += count(OC_Group::usersInGroup($group));
    }
} else {
    $userCountArray = \OC::$server->getUserManager()->countUsers();
    if (!empty($userCountArray)) {
        foreach ($userCountArray as $classname => $usercount) {
            $userCount += $usercount;
        }
    }
}
OC_JSON::success(array('count' => $userCount));
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:20,代码来源:geteveryonecount.php

示例12: explode

$quotaPreset = explode(',', $quotaPreset);
foreach ($quotaPreset as &$preset) {
    $preset = trim($preset);
}
$quotaPreset = array_diff($quotaPreset, array('default', 'none'));
$defaultQuota = OC_Appconfig::getValue('files', 'default_quota', 'none');
$defaultQuotaIsUserDefined = array_search($defaultQuota, $quotaPreset) === false && array_search($defaultQuota, array('none', 'default')) === false;
// load users and quota
foreach ($accessibleusers as $uid => $displayName) {
    $quota = OC_Preferences::getValue($uid, 'files', 'quota', 'default');
    $isQuotaUserDefined = array_search($quota, $quotaPreset) === false && array_search($quota, array('none', 'default')) === false;
    $name = $displayName;
    if ($displayName !== $uid) {
        $name = $name . ' (' . $uid . ')';
    }
    $users[] = array("name" => $uid, "displayName" => $displayName, "groups" => OC_Group::getUserGroups($uid), 'quota' => $quota, 'isQuotaUserDefined' => $isQuotaUserDefined, 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid));
}
foreach ($accessiblegroups as $i) {
    // Do some more work here soon
    $groups[] = array("name" => $i);
}
$tmpl = new OC_Template("settings", "users", "user");
$tmpl->assign('users', $users);
$tmpl->assign('groups', $groups);
$tmpl->assign('isadmin', (int) $isadmin);
$tmpl->assign('subadmins', $subadmins);
$tmpl->assign('numofgroups', count($accessiblegroups));
$tmpl->assign('quota_preset', $quotaPreset);
$tmpl->assign('default_quota', $defaultQuota);
$tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
$tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:users.php

示例13: base32_encode

    $UserTokenSeed = "";
    $UserLocked = "";
    $UserAlgorithm = "";
    $UserPin = "";
    $UserPrefixPin = "";
    //get otp information :
    $OtpExist = $mOtp->CheckUserExists($uid);
    if ($OtpExist) {
        $mOtp->SetUser($uid);
        $UserTokenSeed = base32_encode(hex2bin($mOtp->GetUserTokenSeed()));
        $UserLocked = $mOtp->GetUserLocked();
        $UserAlgorithm = $mOtp->GetUserAlgorithm();
        $UserPin = $mOtp->GetUserPin();
        $UserPrefixPin = $mOtp->GetUserPrefixPin();
    }
    $users[] = array("name" => $uid, "displayName" => $displayName, "groups" => OC_Group::getUserGroups($uid), 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid), 'OtpExist' => $OtpExist, 'UserTokenSeed' => $UserTokenSeed, 'UserLocked' => $UserLocked, 'UserAlgorithm' => $UserAlgorithm, 'UserPin' => $UserPin, 'UserPrefixPin' => $UserPrefixPin);
}
foreach ($accessiblegroups as $i) {
    // Do some more work here soon
    $groups[] = array("name" => $i);
}
$tmpl = new OC_Template("user_otp", "list_users", "user");
$tmpl->assign('PrefixPin', OCP\Config::getAppValue('user_otp', 'UserPrefixPin', '0') ? 1 : 0);
$tmpl->assign('users', $users);
$tmpl->assign('groups', $groups);
$tmpl->assign('isadmin', (int) $isadmin);
$tmpl->assign('subadmins', $subadmins);
$tmpl->assign('numofgroups', count($accessiblegroups));
//~ $tmpl->assign( 'quota_preset', $quotaPreset);
//~ $tmpl->assign( 'default_quota', $defaultQuota);
//~ $tmpl->assign( 'defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
开发者ID:DerRiFlo,项目名称:user-otp,代码行数:31,代码来源:list_users.php

示例14: explode

$quotaPreset = explode(',', $quotaPreset);
foreach ($quotaPreset as &$preset) {
    $preset = trim($preset);
}
$quotaPreset = array_diff($quotaPreset, array('default', 'none'));
$defaultQuota = OC_Appconfig::getValue('files', 'default_quota', 'none');
$defaultQuotaIsUserDefined = array_search($defaultQuota, $quotaPreset) === false && array_search($defaultQuota, array('none', 'default')) === false;
// load users and quota
foreach ($accessibleUsers as $uid => $displayName) {
    $quota = OC_Preferences::getValue($uid, 'files', 'quota', 'default');
    $isQuotaUserDefined = array_search($quota, $quotaPreset) === false && array_search($quota, array('none', 'default')) === false;
    $name = $displayName;
    if ($displayName !== $uid) {
        $name = $name . ' (' . $uid . ')';
    }
    $user = $userManager->get($uid);
    $users[] = array("name" => $uid, "displayName" => $displayName, "groups" => OC_Group::getUserGroups($uid), 'quota' => $quota, 'isQuotaUserDefined' => $isQuotaUserDefined, 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid), 'storageLocation' => $user->getHome(), 'lastLogin' => $user->getLastLogin());
}
$tmpl = new OC_Template("settings", "users/main", "user");
$tmpl->assign('users', $users);
$tmpl->assign('groups', $groups);
$tmpl->assign('adminGroup', $adminGroup);
$tmpl->assign('isAdmin', (int) $isAdmin);
$tmpl->assign('subadmins', $subadmins);
$tmpl->assign('numofgroups', count($groups) + count($adminGroup));
$tmpl->assign('quota_preset', $quotaPreset);
$tmpl->assign('default_quota', $defaultQuota);
$tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
$tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
$tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
$tmpl->printPage();
开发者ID:Romua1d,项目名称:core,代码行数:31,代码来源:users.php

示例15: getSubAdminsOfGroups

 /**
  * Get the groups $uid is SubAdmin of
  * @param string $uid
  * @return array Array of groups that $uid is subadmin of
  */
 function getSubAdminsOfGroups($uid)
 {
     return \OC_SubAdmin::getSubAdminsGroups($uid);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:9,代码来源:subadminfactory.php


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