Restores the default permission settings on the virtual server and returns a new initial
administrator privilege key.

@return TeamSpeak3_Helper_String
552626
public function permReset()
  {
    $token = $this->request("permreset")->toList();

    TeamSpeak3_Helper_Signal::getInstance()->emit("notifyTokencreated", $this, $token["token"]);

    return $token["token"];
  }
316494
public function updateAccess()
    {
        $data = request()->only('role_id', 'permission_id');

        $superAdmin = Roles::superAdmin()->first();

        if( $data['role_id'] == $superAdmin->id ) {
            return \HCLog::info('ACCESS-0001', trans('HCACL::validator.roles.cant_update_super'));
        }

        if( ! auth()->user()->hasRole('admin') && ! auth()->user()->isSuperAdmin() ) {
            return \HCLog::info('ACCESS-0001', trans('HCACL::validator.roles.cant_update_roles'));
        }

        $record = RolesPermissionsConnections::where($data)->first();

        if( is_null($record) ) {
            RolesPermissionsConnections::create($data);
            $message = 'created';
        } else {
            RolesPermissionsConnections::where($data)->delete();
            $message = 'deleted';
        }

        // clear permissions and menu items cache!
        cache()->forget('hc-admin-menu');
        cache()->forget('hc-permissions');

        return ['success' => true, 'message' => $message];
    }
358762
public function getAuthority(): string
    {
        if ($this->host == '') {
            return '';
        }

        $authority = $this->host;
        if ($this->user != '') {
            $authority = $this->user.'@'.$authority;
        }

        if ($this->port !== null && !$this->isDefaultPort($this->scheme, $this->port)) {
            $authority .= ':'.$this->port;
        }

        return $authority;
    }
1119790
public function getPermissions()
    {
        if(!$this->permissions){
            $rolePermissions = $this->rolePermissions();
            $userPermissions = $this->grantedPermissions()->get();

            $permissions = $rolePermissions->merge($userPermissions);
            $deniedPermissions =$this->deniedPermissions()->get();

            $this->permissions = $permissions->filter(function($permission) use ($deniedPermissions)
            {
                return !$deniedPermissions->contains($permission);
            });
        }
        return $this->permissions;
    }
437905
protected function set_default_credentials() {
		$running_servers = Singleton::get_instance( 'Base', $this )->get_running_git_servers();
		$set_credentials = false;
		if ( ! isset( static::$options['gitea_access_token'] ) ) {
			static::$options['gitea_access_token'] = null;
			$set_credentials                       = true;
		}
		if ( empty( static::$options['gitea_access_token'] ) &&
			in_array( 'gitea', $running_servers, true )
		) {
			$this->gitea_error_notices();
		}

		if ( $set_credentials ) {
			add_site_option( 'github_updater', static::$options );
		}
	}
132429
protected function getPermission()
    {
        // Get the display name.  This will go in the 'label' field.
        $label = ucwords($this->ask('Specify the display name for a new permission'));

        $name = null;

        // Make sure we get a valid key name for the permission.
        while (is_null($name)) {
            $name = $this->ask('What should the key name be set to?', Str::slug($label));

            // Make sure they approve the details for the new permission.
            if ($this->confirm("Your permission will be added as: \n\tLabel: $label \n\tName:  $name\nSave this permission?", true)) {
                $data = [
                    'name'       => $name,
                    'label'      => $label,
                    'created_at' => date('Y-m-d H:i:s'),
                ];

                // Add it to the database or detail an error has occurred and a new name needs to be supplied.
                try {
                    $this->db->table('rbac_permissions')->insert($data);
                } catch (QueryException $exception) {
                    $this->error('That name is already taken.  Please choose another.');

                    $name = null;
                    continue;
                }

                // Add the permission to our list.
                $this->permissions[] = (object)$data;

                $this->comment('Added!');
            } else {
                return true;
            }
        }

        // Allow them the chance to add another one.
        return $this->confirm('Add another permission?', true);
    }
1111422
protected function set_default_credentials() {
		$running_servers = Singleton::get_instance( 'Base', $this )->get_running_git_servers();
		$set_credentials = false;
		if ( $this instanceof Bitbucket_API ) {
			$username = 'bitbucket_username';
			$password = 'bitbucket_password';
		}
		if ( $this instanceof Bitbucket_Server_API ) {
			$username = 'bitbucket_server_username';
			$password = 'bitbucket_server_password';
		}
		if ( ! isset( static::$options[ $username ] ) ) {
			static::$options[ $username ] = null;
			$set_credentials              = true;
		}
		if ( ! isset( static::$options[ $password ] ) ) {
			static::$options[ $password ] = null;
			$set_credentials              = true;
		}
		if ( ( empty( static::$options[ $username ] ) || empty( static::$options[ $password ] ) ) &&
			( ( 'bitbucket_username' === $username &&
				in_array( 'bitbucket', $running_servers, true ) ) ||
			( 'bitbucket_server_username' === $username &&
				in_array( 'bbserver', $running_servers, true ) ) )
		) {
			Singleton::get_instance( 'Messages', $this )->create_error_message( 'bitbucket' );
			static::$error_code['bitbucket'] = [ 'code' => 401 ];
		}
		if ( $set_credentials ) {
			add_site_option( 'github_updater', static::$options );
		}
	}
1240348
public function getPermissionAssignmentObject()
    {
        $targ = Core::make('\Concrete\Core\Permission\Assignment\ConversationAssignment');
        if (is_object($this->permissionObject)) {
            $targ->setPermissionObject($this->permissionObject);
        }
        $targ->setPermissionKeyObject($this);

        return $targ;
    }
636615
protected static function get_permissions_name() {
        $strpermissions = array(
            CAP_INHERIT => get_string('inherit', 'role'),
            CAP_ALLOW => get_string('allow', 'role'),
            CAP_PREVENT => get_string('prevent', 'role'),
            CAP_PROHIBIT => get_string('prohibit', 'role')
        );
        return $strpermissions;
    }
182017
protected function getFreshAllPermissions()
    {
        $permissionsRoles = $this->getRolesPermissions(true);

        $permissions = app('defender.permission')->getActivesByUser($this);

        $permissions = $permissions->merge($permissionsRoles)
            ->map(function ($permission) {
                unset($permission->pivot, $permission->created_at, $permission->updated_at);

                return $permission;
            });

        return $permissions->toBase();
    }
1071746
protected function get_permission_strings() {
        static $strpermissions;
        if (!$strpermissions) {
            $strpermissions = array(
                CAP_INHERIT => new lang_string('inherit', 'role'),
                CAP_ALLOW => new lang_string('allow', 'role'),
                CAP_PREVENT => new lang_string('prevent', 'role'),
                CAP_PROHIBIT => new lang_string('prohibit', 'role')
            );
        }
        return $strpermissions;
    }
1242591
public function getUserPermissions()
    {
        $permissions = $this->getPermissions();

        if (!$this->isOwner()) {
            foreach (self::$ownerPermissions as $permission) {
                $key = array_search($permission, $permissions, true);
                if (false !== $key) {
                    unset($permissions[$key]);
                }
            }
        }

        return $permissions;
    }
329097
protected function getPreparedPermissions()
    {
        if ($this->preparedPermissions === null) {
            $this->preparedPermissions = $this->createPreparedPermissions();
        }

        return $this->preparedPermissions;
    }
897225
public static function getRequiredPermissions()
    {
        $class = get_called_class();
        // If the user is accessing LeftAndMain directly, only generic permissions are required.
        if ($class === self::class) {
            return 'CMS_ACCESS';
        }
        $code = Config::inst()->get($class, 'required_permission_codes');
        if ($code === false) {
            return false;
        }
        if ($code) {
            return $code;
        }
        return 'CMS_ACCESS_' . $class;
    }
603363
public function getAuthority()
    {
        $authority = $this->getHost();
        if ($authority === null) {
            return '';
        }

        if ($this->getUserInfo() !== '') {
            $authority = $this->getUserInfo() . '@' . $authority;
        }

        if ($this->port !== null && self::isStandardPort($this->port, $this->scheme, $this->host) === false) {
            $authority .= ':' . $this->port;
        }

        return $authority;
    }
918124
public function getAuthority()
    {
        $userInfo = $this->getUserInfo();

        return rtrim(($userInfo ? $userInfo . '@' : '')
            . $this->host
            . (!$this->isStandardPort($this->scheme, $this->port) ? ':' . $this->port : ''),
            ':');
    }
304323
public function getPermissions()
    {
        $registry = $this->getService('application.registry');
        $key = $this->getIdentifier().'-permissions';

        if (!$registry->offsetExists($key)) {
            $registry->offsetSet($key, self::_getDefaultPermissions($this));
        }

        return $registry->offsetGet($key);
    }