本文整理汇总了PHP中OC_User::isAdminUser方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::isAdminUser方法的具体用法?PHP OC_User::isAdminUser怎么用?PHP OC_User::isAdminUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::isAdminUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($AppName, IRequest $Request, $CurrentUID, IL10N $L10N)
{
parent::__construct($AppName, $Request);
$this->CurrentUID = $CurrentUID;
$this->L10N = $L10N;
if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
$this->DbType = 1;
}
$this->CanCheckForUpdate = Tools::CanCheckForUpdate();
$this->Settings = new Settings();
$this->Settings->SetKey('WhichDownloader');
$this->WhichDownloader = $this->Settings->GetValue();
$this->WhichDownloader = is_null($this->WhichDownloader) ? 'ARIA2' : $this->WhichDownloader;
$this->Settings->SetKey('AllowProtocolHTTP');
$this->AllowProtocolHTTP = $this->Settings->GetValue();
$this->AllowProtocolHTTP = is_null($this->AllowProtocolHTTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolHTTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolFTP');
$this->AllowProtocolFTP = $this->Settings->GetValue();
$this->AllowProtocolFTP = is_null($this->AllowProtocolFTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolFTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolYT');
$this->AllowProtocolYT = $this->Settings->GetValue();
$this->AllowProtocolYT = is_null($this->AllowProtocolYT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolYT, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolBT');
$this->AllowProtocolBT = $this->Settings->GetValue();
$this->AllowProtocolBT = is_null($this->AllowProtocolBT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolBT, 'Y') == 0;
}
示例2: checkAdminUser
/**
* Check if the user is a admin, send json error msg if not
*/
public static function checkAdminUser()
{
if (!OC_User::isAdminUser(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array('data' => array('message' => $l->t('Authentication error'))));
exit;
}
}
示例3: checkAdminUser
/**
* Check if the user is a admin, send json error msg if not.
* @deprecated Use annotation based ACLs from the AppFramework instead
*/
public static function checkAdminUser()
{
if (!OC_User::isAdminUser(OC_User::getUser())) {
$l = \OC::$server->getL10N('lib');
self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
exit;
}
}
示例4: Add
public static function Add($URL)
{
try {
self::Load();
$URL = urldecode($URL);
if (Tools::CheckURL($URL)) {
if (preg_match('/^https{0,1}:\\/\\/www\\.youtube\\.com\\/watch\\?v=.*$/', $URL) == 1) {
if (!self::$AllowProtocolYT && !\OC_User::isAdminUser(self::$CurrentUID)) {
return array('ERROR' => true, 'MESSAGE' => 'Notallowedtouseprotocolyt');
}
$YouTube = new YouTube(self::$YTDLBinary, $URL);
if (!is_null(self::$ProxyAddress) && self::$ProxyPort > 0 && self::$ProxyPort <= 65536) {
$YouTube->SetProxy(self::$ProxyAddress, self::$ProxyPort);
}
$VideoData = $YouTube->GetVideoData();
if (!isset($VideoData['VIDEO']) || !isset($VideoData['FULLNAME'])) {
return array('ERROR' => true, 'MESSAGE' => 'UnabletoretrievetrueYouTubevideoURL');
}
$DL = array('URL' => $VideoData['VIDEO'], 'FILENAME' => Tools::CleanString($VideoData['FULLNAME']), 'PROTO' => 'Video');
} else {
if (!self::$AllowProtocolHTTP && !\OC_User::isAdminUser(self::$CurrentUID) && Tools::StartsWith(strtolower($URL), 'http')) {
return array('ERROR' => true, 'MESSAGE' => 'Notallowedtouseprotocolhttp');
} elseif (!self::$AllowProtocolFTP && !\OC_User::isAdminUser(self::$CurrentUID) && Tools::StartsWith(strtolower($URL), 'ftp')) {
return array('ERROR' => true, 'MESSAGE' => 'Notallowedtouseprotocolftp');
}
$DL = array('URL' => $URL, 'FILENAME' => Tools::CleanString(substr($URL, strrpos($URL, '/') + 1)), 'PROTO' => strtoupper(substr($URL, 0, strpos($URL, ':'))));
}
$OPTIONS = array('dir' => self::$AbsoluteDownloadsFolder, 'out' => $DL['FILENAME'], 'follow-torrent' => false);
if (!is_null(self::$ProxyAddress) && self::$ProxyPort > 0 && self::$ProxyPort <= 65536) {
$OPTIONS['all-proxy'] = rtrim(self::$ProxyAddress, '/') . ':' . self::$ProxyPort;
if (!is_null(self::$ProxyUser) && !is_null(self::$ProxyPasswd)) {
$OPTIONS['all-proxy-user'] = self::$ProxyUser;
$OPTIONS['all-proxy-passwd'] = self::$ProxyPasswd;
}
}
$AddURI = self::$WhichDownloader == 0 ? Aria2::AddUri(array($DL['URL']), array('Params' => $OPTIONS)) : CURL::AddUri($DL['URL'], $OPTIONS);
if (isset($AddURI['result']) && !is_null($AddURI['result'])) {
$SQL = 'INSERT INTO `*PREFIX*ocdownloader_queue` (`UID`, `GID`, `FILENAME`, `PROTOCOL`, `IS_CLEANED`, `STATUS`, `TIMESTAMP`) VALUES (?, ?, ?, ?, ?, ?, ?)';
if (self::$DbType == 1) {
$SQL = 'INSERT INTO *PREFIX*ocdownloader_queue ("UID", "GID", "FILENAME", "PROTOCOL", "IS_CLEANED", "STATUS", "TIMESTAMP") VALUES (?, ?, ?, ?, ?, ?, ?)';
}
$Query = \OCP\DB::prepare($SQL);
$Result = $Query->execute(array(self::$CurrentUID, $AddURI['result'], $DL['FILENAME'], strcmp($DL['PROTO'], 'Video') == 0 ? 'YT ' . (string) self::$L10N->t('Video') : $DL['PROTO'], 1, 1, time()));
return array('ERROR' => false, 'FILENAME' => $DL['FILENAME']);
} else {
return array('ERROR' => true, 'MESSAGE' => 'ReturnedGIDisnullIsAria2crunningasadaemon');
}
} else {
return array('ERROR' => true, 'MESSAGE' => 'InvalidURL');
}
} catch (Exception $E) {
return array('ERROR' => true, 'MESSAGE' => 'Unabletolaunchthedownload');
}
}
示例5: 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');
}
}
示例6: getUserPrivatekey
public static function getUserPrivatekey($parameters)
{
$user = OC_User::getUser();
if (OC_User::isAdminUser($user) or $user == $parameters['user']) {
if (OC_User::userExists($user)) {
// calculate the disc space
$txt = 'this is the private key of ' . $parameters['user'];
echo $txt;
} else {
return new OC_OCS_Result(null, 300, 'User does not exist');
}
} else {
return new OC_OCS_Result('null', 300, 'You don´t have permission to access this ressource.');
}
}
示例7: deleteComment
public static function deleteComment($id)
{
if (!USER_CONVERSATIONS_CAN_DELETE) {
return false;
}
$query = OCP\DB::prepare('SELECT author FROM *PREFIX*conversations WHERE id = ?');
$result = $query->execute(array($id))->fetch();
$uid = OC_User::getUser();
if ($result['author'] == $uid || OC_User::isAdminUser($uid)) {
$query = OCP\DB::prepare('DELETE FROM *PREFIX*conversations WHERE id = ?');
$query->execute(array($id));
return true;
} else {
return false;
}
}
示例8: getUser
/**
* gets user info
*
* exposes the quota of an user:
* <data>
* <quota>
* <free>1234</free>
* <used>4321</used>
* <total>5555</total>
* <ralative>0.78</ralative>
* </quota>
* </data>
*
* @param array $parameters should contain parameter 'userid' which identifies
* the user from whom the information will be returned
*/
public static function getUser($parameters)
{
$return = array();
// Check if they are viewing information on themselves
if ($parameters['userid'] === OC_User::getUser()) {
// Self lookup
$storage = OC_Helper::getStorageInfo('/');
$return['quota'] = array('free' => $storage['free'], 'used' => $storage['used'], 'total' => $storage['total'], 'relative' => $storage['relative']);
}
if (OC_User::isAdminUser(OC_User::getUser()) || OC_Subadmin::isUserAccessible(OC_User::getUser(), $parameters['userid'])) {
if (OC_User::userExists($parameters['userid'])) {
// Is an admin/subadmin so can see display name
$return['displayname'] = OC_User::getDisplayName($parameters['userid']);
} else {
return new OC_OCS_Result(null, 101);
}
}
if (count($return)) {
return new OC_OCS_Result($return);
} else {
// No permission to view this user data
return new OC_OCS_Result(null, 997);
}
}
示例9: header
// Set the content type to Javascript
header("Content-type: text/javascript");
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Enable l10n support
$l = \OC::$server->getL10N('core');
// Enable OC_Defaults support
$defaults = new OC_Defaults();
// Get the config
$apps_paths = array();
foreach (OC_App::getEnabledApps() as $app) {
$apps_paths[$app] = OC_App::getAppWebPath($app);
}
$config = \OC::$server->getConfig();
$value = $config->getAppValue('core', 'shareapi_default_expire_date', 'no');
$defaultExpireDateEnabled = $value === 'yes' ? true : false;
$defaultExpireDate = $enforceDefaultExpireDate = null;
if ($defaultExpireDateEnabled) {
$defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
$value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
$enforceDefaultExpireDate = $value === 'yes' ? true : false;
}
$outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes';
$array = array("oc_debug" => defined('DEBUG') && DEBUG ? 'true' : 'false', "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false', "oc_webroot" => "\"" . OC::$WEBROOT . "\"", "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), "datepickerFormatDate" => json_encode($l->getDateFormat()), "dayNames" => json_encode(array((string) $l->t('Sunday'), (string) $l->t('Monday'), (string) $l->t('Tuesday'), (string) $l->t('Wednesday'), (string) $l->t('Thursday'), (string) $l->t('Friday'), (string) $l->t('Saturday'))), "monthNames" => json_encode(array((string) $l->t('January'), (string) $l->t('February'), (string) $l->t('March'), (string) $l->t('April'), (string) $l->t('May'), (string) $l->t('June'), (string) $l->t('July'), (string) $l->t('August'), (string) $l->t('September'), (string) $l->t('October'), (string) $l->t('November'), (string) $l->t('December'))), "firstDay" => json_encode($l->getFirstWeekDay()), "oc_config" => json_encode(array('session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), ini_get('session.gc_maxlifetime')), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true), 'version' => implode('.', OC_Util::getVersion()), 'versionstring' => OC_Util::getVersionString(), 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true))), "oc_appconfig" => json_encode(array("core" => array('defaultExpireDateEnabled' => $defaultExpireDateEnabled, 'defaultExpireDate' => $defaultExpireDate, 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), 'resharingAllowed' => \OCP\Share::isResharingAllowed(), 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, 'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated')))), "oc_defaults" => json_encode(array('entity' => $defaults->getEntity(), 'name' => $defaults->getName(), 'title' => $defaults->getTitle(), 'baseUrl' => $defaults->getBaseUrl(), 'syncClientUrl' => $defaults->getSyncClientUrl(), 'docBaseUrl' => $defaults->getDocBaseUrl(), 'slogan' => $defaults->getSlogan(), 'logoClaim' => $defaults->getLogoClaim(), 'shortFooter' => $defaults->getShortFooter(), 'longFooter' => $defaults->getLongFooter())));
// Allow hooks to modify the output values
OC_Hook::emit('\\OCP\\Config', 'js', array('array' => &$array));
// Echo it
foreach ($array as $setting => $value) {
echo "var " . $setting . "=" . $value . ";\n";
}
示例10: isAdminUser
/**
* @return boolean
*/
function isAdminUser()
{
$uid = $this->getUserId();
return \OC_User::isAdminUser($uid);
}
示例11: __construct
/**
* @param array $urlParams
*/
public function __construct(array $urlParams = [])
{
parent::__construct('settings', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('MailSettingsController', function (IContainer $c) {
return new MailSettingsController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('Config'), $c->query('UserSession'), $c->query('Defaults'), $c->query('Mailer'), $c->query('DefaultMailAddress'));
});
$container->registerService('EncryptionController', function (IContainer $c) {
return new EncryptionController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('Config'), $c->query('DatabaseConnection'), $c->query('UserManager'), new View(), $c->query('Logger'));
});
$container->registerService('AppSettingsController', function (IContainer $c) {
return new AppSettingsController($c->query('AppName'), $c->query('Request'), $c->query('L10N'), $c->query('Config'), $c->query('ICacheFactory'), $c->query('INavigationManager'), $c->query('IAppManager'), $c->query('OcsClient'));
});
$container->registerService('AuthSettingsController', function (IContainer $c) {
return new AuthSettingsController($c->query('AppName'), $c->query('Request'), $c->query('ServerContainer')->query('OC\\Authentication\\Token\\IProvider'), $c->query('UserManager'), $c->query('ServerContainer')->getSession(), $c->query('ServerContainer')->getSecureRandom(), $c->query('UserId'));
});
$container->registerService('SecuritySettingsController', function (IContainer $c) {
return new SecuritySettingsController($c->query('AppName'), $c->query('Request'), $c->query('Config'));
});
$container->registerService('CertificateController', function (IContainer $c) {
return new CertificateController($c->query('AppName'), $c->query('Request'), $c->query('CertificateManager'), $c->query('SystemCertificateManager'), $c->query('L10N'), $c->query('IAppManager'));
});
$container->registerService('GroupsController', function (IContainer $c) {
return new GroupsController($c->query('AppName'), $c->query('Request'), $c->query('GroupManager'), $c->query('UserSession'), $c->query('IsAdmin'), $c->query('L10N'));
});
$container->registerService('UsersController', function (IContainer $c) {
return new UsersController($c->query('AppName'), $c->query('Request'), $c->query('UserManager'), $c->query('GroupManager'), $c->query('UserSession'), $c->query('Config'), $c->query('IsAdmin'), $c->query('L10N'), $c->query('Logger'), $c->query('Defaults'), $c->query('Mailer'), $c->query('DefaultMailAddress'), $c->query('URLGenerator'), $c->query('OCP\\App\\IAppManager'), $c->query('OCP\\IAvatarManager'));
});
$container->registerService('LogSettingsController', function (IContainer $c) {
return new LogSettingsController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
});
$container->registerService('CheckSetupController', function (IContainer $c) {
return new CheckSetupController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('ClientService'), $c->query('URLGenerator'), $c->query('Util'), $c->query('L10N'), $c->query('Checker'));
});
/**
* Middleware
*/
$container->registerService('SubadminMiddleware', function (IContainer $c) {
return new SubadminMiddleware($c->query('ControllerMethodReflector'), $c->query('IsSubAdmin'));
});
// Execute middlewares
$container->registerMiddleware('SubadminMiddleware');
/**
* Core class wrappers
*/
$container->registerService('Config', function (IContainer $c) {
return $c->query('ServerContainer')->getConfig();
});
$container->registerService('ICacheFactory', function (IContainer $c) {
return $c->query('ServerContainer')->getMemCacheFactory();
});
$container->registerService('L10N', function (IContainer $c) {
return $c->query('ServerContainer')->getL10N('settings');
});
$container->registerService('GroupManager', function (IContainer $c) {
return $c->query('ServerContainer')->getGroupManager();
});
$container->registerService('UserManager', function (IContainer $c) {
return $c->query('ServerContainer')->getUserManager();
});
$container->registerService('UserSession', function (IContainer $c) {
return $c->query('ServerContainer')->getUserSession();
});
/** FIXME: Remove once OC_User is non-static and mockable */
$container->registerService('IsAdmin', function (IContainer $c) {
return \OC_User::isAdminUser(\OC_User::getUser());
});
/** FIXME: Remove once OC_SubAdmin is non-static and mockable */
$container->registerService('IsSubAdmin', function (IContainer $c) {
$userObject = \OC::$server->getUserSession()->getUser();
$isSubAdmin = false;
if ($userObject !== null) {
$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
}
return $isSubAdmin;
});
$container->registerService('Mailer', function (IContainer $c) {
return $c->query('ServerContainer')->getMailer();
});
$container->registerService('Defaults', function (IContainer $c) {
return new \OC_Defaults();
});
$container->registerService('DefaultMailAddress', function (IContainer $c) {
return Util::getDefaultEmailAddress('no-reply');
});
$container->registerService('Logger', function (IContainer $c) {
return $c->query('ServerContainer')->getLogger();
});
$container->registerService('URLGenerator', function (IContainer $c) {
return $c->query('ServerContainer')->getURLGenerator();
});
$container->registerService('ClientService', function (IContainer $c) {
return $c->query('ServerContainer')->getHTTPClientService();
});
//.........这里部分代码省略.........
示例12: isAuthorised
/**
* authenticate the api call
* @param array $action the action details as supplied to OC_API::register()
* @return bool
*/
private static function isAuthorised($action)
{
$level = $action['authlevel'];
switch ($level) {
case API::GUEST_AUTH:
// Anyone can access
return true;
case API::USER_AUTH:
// User required
return self::loginUser();
case API::SUBADMIN_AUTH:
// Check for subadmin
$user = self::loginUser();
if (!$user) {
return false;
} else {
$userObject = \OC::$server->getUserSession()->getUser();
if ($userObject === null) {
return false;
}
$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
$admin = OC_User::isAdminUser($user);
if ($isSubAdmin || $admin) {
return true;
} else {
return false;
}
}
case API::ADMIN_AUTH:
// Check for admin
$user = self::loginUser();
if (!$user) {
return false;
} else {
return OC_User::isAdminUser($user);
}
default:
// oops looks like invalid level supplied
return false;
}
}
示例13: getSettingsNavigation
/**
* Returns the Settings Navigation
* @return string
*
* This function returns an array containing all settings pages added. The
* entries are sorted by the key 'order' ascending.
*/
public static function getSettingsNavigation()
{
$l = \OC::$server->getL10N('lib');
$settings = array();
// by default, settings only contain the help menu
if (OC_Util::getEditionString() === '' && OC_Config::getValue('knowledgebaseenabled', true) == true) {
$settings = array(array("id" => "help", "order" => 1000, "href" => OC_Helper::linkToRoute("settings_help"), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath("settings", "help.svg")));
}
// if the user is logged-in
if (OC_User::isLoggedIn()) {
// personal menu
$settings[] = array("id" => "personal", "order" => 1, "href" => OC_Helper::linkToRoute("settings_personal"), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath("settings", "personal.svg"));
// if there are some settings forms
if (!empty(self::$settingsForms)) {
// settings menu
$settings[] = array("id" => "settings", "order" => 1000, "href" => OC_Helper::linkToRoute("settings_settings"), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath("settings", "settings.svg"));
}
//SubAdmins are also allowed to access user management
if (OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
// admin users menu
$settings[] = array("id" => "core_users", "order" => 2, "href" => OC_Helper::linkToRoute("settings_users"), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath("settings", "users.svg"));
}
// if the user is an admin
if (OC_User::isAdminUser(OC_User::getUser())) {
// admin settings
$settings[] = array("id" => "admin", "order" => 1000, "href" => OC_Helper::linkToRoute("settings_admin"), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath("settings", "admin.svg"));
}
}
$navigation = self::proceedNavigation($settings);
return $navigation;
}
示例14: array
*/
OC_Util::checkSubAdminUser();
OC_App::setActiveNavigationEntry('core_users');
$userManager = \OC_User::getManager();
$groupManager = \OC_Group::getManager();
// Set the sort option: SORT_USERCOUNT or SORT_GROUPNAME
$sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
if (\OC_App::isEnabled('user_ldap')) {
$isLDAPUsed = $groupManager->isBackendUsed('\\OCA\\user_ldap\\GROUP_LDAP') || $groupManager->isBackendUsed('\\OCA\\user_ldap\\Group_Proxy');
if ($isLDAPUsed) {
// LDAP user count can be slow, so we sort by group name here
$sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
}
}
$config = \OC::$server->getConfig();
$isAdmin = OC_User::isAdminUser(OC_User::getUser());
$groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), $isAdmin, $groupManager);
$groupsInfo->setSorting($sortGroupsBy);
list($adminGroup, $groups) = $groupsInfo->get();
$recoveryAdminEnabled = OC_App::isEnabled('encryption') && $config->getAppValue('encryption', 'recoveryAdminEnabled', null);
if ($isAdmin) {
$subadmins = OC_SubAdmin::getAllSubAdmins();
} else {
/* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
$gids = array();
foreach ($groups as $group) {
if (isset($group['id'])) {
$gids[] = $group['id'];
}
}
$subadmins = false;
示例15: isAuthorised
/**
* authenticate the api call
* @param array $action the action details as supplied to OC_API::register()
* @return bool
*/
private static function isAuthorised($action)
{
$level = $action['authlevel'];
switch ($level) {
case API::GUEST_AUTH:
// Anyone can access
return true;
break;
case API::USER_AUTH:
// User required
return self::loginUser();
break;
case API::SUBADMIN_AUTH:
// Check for subadmin
$user = self::loginUser();
if (!$user) {
return false;
} else {
$subAdmin = OC_SubAdmin::isSubAdmin($user);
$admin = OC_User::isAdminUser($user);
if ($subAdmin || $admin) {
return true;
} else {
return false;
}
}
break;
case API::ADMIN_AUTH:
// Check for admin
$user = self::loginUser();
if (!$user) {
return false;
} else {
return OC_User::isAdminUser($user);
}
break;
default:
// oops looks like invalid level supplied
return false;
break;
}
}