sets new umask setting and returns previous umask setting

If no value is given only the current umask setting is returned.

@param   int|null  $umask  new umask setting
@return  int
@since   0.8.0
11707
public static function umask(int $umask = null): int
    {
        $oldUmask = self::$umask;
        if (null !== $umask) {
            self::$umask = $umask;
        }

        return $oldUmask;
    }
452150
protected function getPrev()
    {
        if (!$this->current)
        {
            return null;
        }
        if ($this->prev !== -1)
        {
            return $this->prev;
        }
        $this->load();
        for ($i = 0; $i < count($this->items); $i++)
        {
            if ($this->items[$i]->id == $this->current->id)
            {
                if ($i > 0)
                {
                    $this->prev = $this->items[$i - 1];
                    return $this->prev;
                }
                break;
            }
        }
        return null;
    }
742721
public function first(Request $request)
    {
        // We should only be here for creating the first user
        if ($this->app['schema']->hasUserTable() && $this->users()->hasUsers()) {
            return $this->redirectToRoute('dashboard');
        }

        // Add a note, if we're setting up the first user using SQLite.
        $dbdriver = $this->getOption('general/database/driver');
        if ($dbdriver === 'sqlite' || $dbdriver === 'pdo_sqlite') {
            $note = Trans::__('page.edit-users.note-sqlite');
        } else {
            $note = '';
        }

        // If we get here, chances are we don't have the tables set up, yet.
        $this->app['schema']->update();

        // Get an new entity object
        $userEntity = $this->getUserEntity();
        $userEntity->setEnabled(true);
        // Grant 'root' to first user by default
        $userEntity->setRoles([Permissions::ROLE_ROOT]);

        // Generate the form
        $form = $this->createFormBuilder(FormType\UserNewType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;

        if ($form->isSubmitted() && $form->isValid()) {
            /** @var \Bolt\Form\FormType\UserData $data */
            $data = $form->getData();
            $data->applyToEntity($userEntity);
            $saved = $this->getRepository(Entity\Users::class)->save($userEntity);
            if ($saved) {
                $this->app['logger.system']->info(
                    Trans::__('page.edit-users.log.user-added', ['%user%' => $userEntity->getDisplayname()]),
                    ['event' => 'security']
                );
                $this->notifyUserSetupEmail($request, $userEntity->getDisplayname(), $userEntity->getEmail());

                $event = new AccessControlEvent($request);
                $login = $this->login()->login($userEntity->getUsername(), $form->get('password')->getData(), $event);
                $token = $this->session()->get('authentication');
                if ($login && $token) {
                    $this->flashes()->clear();
                    $this->flashes()->success(Trans::__('general.bolt-welcome-new-site', ['%USER%' => $userEntity->getDisplayname()]));

                    /** @var RedirectResponse $response */
                    $response = $this->setAuthenticationCookie($request, $this->redirectToRoute('dashboard'), (string) $token);

                    return $response;
                }
                if (!$token) {
                    $this->flashes()->error(Trans::__('general.phrase.error-session-data-login'));
                } else {
                    $this->flashes()->error(Trans::__('general.phrase.something-went-wrong-after-first-user'));
                }
            }
        }

        /** @var RequirementCollection $requirements */
        $requirements = $this->app['requirements'];
        $context = [
            'required'    => $requirements->getFailedRequirements() ?: null,
            'recommended' => $requirements->getFailedRecommendations() ?: null,
            'kind'        => 'create',
            'form'        => $form->createView(),
            'note'        => $note,
            'displayname' => $userEntity->getDisplayname(),
            'sitename'    => $this->getOption('general/sitename'),
        ];

        return $this->render('@bolt/firstuser/firstuser.twig', $context);
    }
883017
public function setRequest(array $request)
    {
        parent::setRequest($request);

        if (isset($this->_request->term)) {
            $value = $this->getService('anahita:filter.term')->sanitize($this->_request->term);
            $this->_request->term = $value;
            $this->term = $value;
        }

        if (isset($this->_request->search_range)) {
            $value = (int) $this->_request->search_range;
            $this->_request->search_range = $value;
            $this->search_range = $value;
        }

        if ($this->_request->search_comments == 1 || $this->_request->search_comments == 'true') {
           $value = true;
        } else {
           $value = false;
        }

        $this->_request->search_comments = $value;
        $this->search_comments = $value;

        return $this;
    }
88873
public function current()
    {
        if ($this->current instanceof TerminalBucket) {
            return null;
        }

        /** @var KeyValueBucket $current */
        $current = $this->current;

        return $current->value();
    }
1221468
public function getSettingsRecord()
    {
        $item = UserPreference::forUser();
        $record = $item
            ->scopeApplyKeyAndUser($this->model, $this->recordCode, $item->userContext)
            ->remember(1440, $this->getCacheKey())
            ->first();

        return $record ?: null;
    }
181205
public function getCurrentRequestContent()
    {
        if ($this->requestStack->getCurrentRequest() instanceof Request) {
            return $this->requestStack->getCurrentRequest()->getContent();
        }
        return null;
    }
501243
public function getCurrentRequestMethod()
    {
        if ($this->requestStack->getCurrentRequest() instanceof Request) {
            return $this->requestStack->getCurrentRequest()->getMethod();
        }
        return null;
    }
805564
def _umask(self):
        """"""
        if self.filesystem.is_windows_fs:
            # windows always returns 0 - it has no real notion of umask
            return 0
        if sys.platform == 'win32':
            # if we are testing Unix under Windows we assume a default mask
            return 0o002
        else:
            # under Unix, we return the real umask;
            # as there is no pure getter for umask, so we have to first
            # set a mode to get the previous one and then re-set that
            mask = os.umask(0)
            os.umask(mask)
            return mask
603765
public function retrieveCurrent(Request $request)
    {
        if (ConfigQuery::isRewritingEnable()) {
            $view = $request->attributes->get('_view', null);

            $viewLocale = $this->getViewLocale($request);

            $viewId = $view === null ? null : $request->query->get($view . '_id', null);

            $allOtherParameters = $request->query->all();
            if ($view !== null) {
                unset($allOtherParameters['view']);
                if ($viewId !== null) {
                    unset($allOtherParameters[$view . '_id']);
                }
            }
            if ($viewLocale !== null) {
                unset($allOtherParameters['lang']);
                unset($allOtherParameters['locale']);
            }

            $this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
        } else {
            $allParametersWithoutView = $request->query->all();
            $view = $request->attributes->get('_view');
            if (isset($allOtherParameters['view'])) {
                unset($allOtherParameters['view']);
            }
            $this->retriever->rewrittenUrl = null;
            $this->retriever->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
        }

        return $this->retriever;
    }
475840
protected function _setCurrentUser($user = null)
    {
        if ($user === null && !empty($this->Auth)) {
            $user = $this->Auth->user();
        }

        if (!$user) {
            return false;
        }

        $this->_currentUserInstance = $this->_getUserInstance($user);

        return $this->_currentUserInstance;
    }
277125
public function limit($request) {
        $limit = (int)$request->getVar('limit');
        if($limit && is_int($limit) && $limit > 0) {
            return $limit;
        } else {
            return static::$default_limit;
        }
    }
197057
public function setUUid($uuid = null)
    {
        $notAllowedNames = [
            ListRepositoryInterface::CHUNK,
            ListRepositoryInterface::HEADERS,
            ListRepositoryInterface::INDEX,
            ListRepositoryInterface::SEPARATOR,
            ListRepositoryInterface::STATISTICS,
        ];

        foreach ($notAllowedNames as $notAllowedName) {
            if (strpos($uuid, $notAllowedName) !== false) {
                throw new ListElementNotAllowedUuidException('You can\'t assign "'.$uuid.'" as element uuid.');
            }
        }

        $this->uuid = str_replace(' ', '-', $uuid) ?: Uuid::uuid4()->toString();
    }
1268296
public function index(Request $request)
    {
        $limit = 20;
        $prev = null;
        $user = $request->user();

        $this->validate($request, [
            'since'     => 'iso8601',
            'until'     => 'iso8601',
            'cursor'    => 'uuid',
            'tag_id'    => 'uuid',
            'source_id' => 'uuid',
            ]);

        $dids = $user->dids()
            ->fullTextSearchFilter($request->q, $user->id)
            ->tagFilter($request->tag_id)
            ->sourceFilter($request->source_id)
            ->cursorFilter($request->cursor)
            ->dateFilter($request->since, $request->until)
            ->with(['tags', 'source'])
            ->orderBy(DB::raw('uuid_v1_timestamp(id)'), 'DESC')
            ->limit($limit)->get();

        // if the cursor is being passed in then we need to obtain the previous id.
        if(!empty($request->cursor)){
            $dids_prev = $user->dids()
                ->fullTextSearchFilter($request->q, $user->id)
                ->tagFilter($request->tag_id)
                ->sourceFilter($request->source_id)
                ->prevFilter($request->cursor)
                ->dateFilter($request->since, $request->until)
                ->orderBy(DB::raw('uuid_v1_timestamp(id)'), 'ASC')
                ->limit($limit)->get();

            if($dids_prev->count() == $limit) $prev = $dids_prev->last()->id;
        }

        $results = fractal()
            ->collection($dids, new DidTransformer())
            ->withCursor(new Cursor($request->cursor, $prev, $dids, $limit));

        return response()->json($results);
    }
296533
public function get($key)
    {
        if (!$this->has($key)) {
            return null;
        }

        return (new SettingModel)
            ->cached()
            ->where('key', $key)
            ->first()
            ->value;
    }
815237
private function setGet()
    {
        if (isset($_GET)) {
            foreach ($_GET as $k => $v) {
                $this->log->debug("[ GET Params ]" . $k . ": " . $v, []);
                $this->get->$k = $this->setSecurityLevel($v);
                $this->parameters["get"][$k] = $this->setSecurityLevel($v);
            }
            unset($_GET);
        }
    }
79475
public function getUuid() : ?string 
    {
        if ( ! $this->hasUuid()) {
            $this->setUuid($this->getDefaultUuid());
        }
        return $this->uuid;
    }