@param User $user
@param Post $post

@return bool
332096
public function create($user, $post)
    {
        return $this->postPolicy->create($user, $post)
            && $user->can('blog.comment.edit');
    }
403102
public function setCoins(UserInterface $user, $coins)
    {
        $class = $this->getGameOptions()->getEntityAccountClass();
        $accEntityManager = $this->getAccountEntityManager();

        /** @var \GameBackend\Entity\Metin\Account\Repository\Account $repoAccount */
        $repoAccount = $accEntityManager->getRepository($class);
        $metinUser = $repoAccount->getUser($user);

        if (!$metinUser) {
            return false;
        }

        $metinUser->setCash($metinUser->getCash() + $coins);
        if ($metinUser->getCash() < 0) {
            return false;
        }

        $accEntityManager->persist($metinUser);
        $accEntityManager->flush();

        return true;
    }
1339787
public function formAction(User $user)
    {
        return array(
            'form' => $this->formFactory->create(FormFactory::TYPE_EMAIL)->createView(),
            'userId' => $user->getId()
        );
    }
1068672
public function addUser(User $user)
    {
        if (!$this->users->contains($user)) {
            $this->users->add($user);
        }

        return $this;
    }
395545
public function store(CreateUserRequest $request, User $user)
    {
        $this->authorize(UsersPolicy::PERMISSION_CREATE);

        $user->fill($request->getValidatedData());
        $user->is_active = true;
        $user->save();
        $user->roles()->sync($request->get('roles'));

        $this->transNotification('created', ['name' => $user->full_name], $user->toArray());

        return redirect()->route('admin::auth.users.index');
    }
130291
public function postAuthProcess(Request $request, User $user)
    {
        $date = new \DateTime('+' . (int) $this->getConf()->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
        $manager = $this->getEntityManager();

        foreach ($this->getValidationParticipantRepository()->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
            $validationSession = $participant->getSession();
            $basket = $validationSession->getBasket();

            if (null === $token = $this->getTokenRepository()->findValidationToken($basket, $participant->getUser())) {
                continue;
            }

            $url = $this->app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
            $this->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));

            $participant->setReminded(new \DateTime('now'));
            $manager->persist($participant);
        }

        $manager->flush();

        $session = $this->getAuthenticator()->openAccount($user);

        if ($user->getLocale() != $this->app['locale']) {
            $user->setLocale($this->app['locale']);
        }

        $width = $height = null;
        if ($request->cookies->has('screen')) {
            $data = array_filter((explode('x', $request->cookies->get('screen', ''))));
            if (count($data) === 2) {
                $width = $data[0];
                $height = $data[1];
            }
        }
        $session->setIpAddress($request->getClientIp())
            ->setScreenHeight($height)
            ->setScreenWidth($width);

        $manager->persist($session);
        $manager->flush();

        return $session;
    }
196570
public function isPublisher(User $user)
    {
        if ($this->publisher) {
            if ($this->publisher->getUser()->getId() === $user->getId()) {
                return true;
            }
        }

        return false;
    }
1348644
public function deleteUser($user) {
    if($this->userExists($user)) {
      $pattern = '/'.$user.'.*/';
      $this->htpwd = array_filter($this->htpwd,function($line) use ($pattern) {
        return (preg_match($pattern,$line) != 1);
      });
      $this->_save();
      return true;
    } else {
      return false;
    }
  }
477864
public function update(UserRequest $request, User $user)
    {
        $user->update($request->all());

        return $this->makeRedirect(true, 'admin.users.index', __('update'));
    }
1217500
public function createUser(User $user)
    {
        $query = $this->handler->createInsertQuery();
        $query
            ->insertInto($this->handler->quoteTable('ezuser'))
            ->set(
                $this->handler->quoteColumn('contentobject_id'),
                $query->bindValue($user->id, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('login'),
                $query->bindValue($user->login)
            )->set(
                $this->handler->quoteColumn('email'),
                $query->bindValue($user->email)
            )->set(
                $this->handler->quoteColumn('password_hash'),
                $query->bindValue($user->passwordHash)
            )->set(
                $this->handler->quoteColumn('password_hash_type'),
                $query->bindValue($user->hashAlgorithm, null, \PDO::PARAM_INT)
            );
        $query->prepare()->execute();

        $query = $this->handler->createInsertQuery();
        $query
            ->insertInto($this->handler->quoteTable('ezuser_setting'))
            ->set(
                $this->handler->quoteColumn('user_id'),
                $query->bindValue($user->id, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('is_enabled'),
                $query->bindValue($user->isEnabled, null, \PDO::PARAM_INT)
            )->set(
                $this->handler->quoteColumn('max_login'),
                $query->bindValue($user->maxLogin, null, \PDO::PARAM_INT)
            );
        $query->prepare()->execute();
    }
265199
public static function delete_by_user_id($user_id = null)
	{
		if (empty($user_id))
		{
			return true;
		}

		$results = self::all()
			->whereEquals('user_id', $user_id)
			->rows();

		foreach ($results as $result)
		{
			if (!$result->destroy())
			{
				return false;
			}
		}

		return true;
	}
1131959
public function get_from_user_and_posts(stdClass $user, array $posts) {
        $postids = array_map(function($post) {
            return $post->get_id();
        }, $posts);
        return $this->get_from_user_id_and_post_ids($user->id, $postids);
    }
790997
public function userHasAccess(User $user)
    {
        if ($this->getWhitelisted() === false) {
            return true;
        }

        $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('user', $user))
                ->setMaxResults(1);

        $serverUsers = $this->users->matching($criteria);
        if ($serverUsers->count() === 0) {
            return false;
        }

        $serverUser = $serverUsers->first();

        if ($serverUser->getBanned() === true) {
            return false;
        }

        if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) {
            return false;
        }

        return true;
    }
495181
public function can_export_post(stdClass $user, post_entity $post) : bool {
        global $CFG;
        $context = $this->get_context();
        return $CFG->enableportfolios  && (has_capability('mod/forum:exportpost', $context, $user) ||
            ($post->is_owned_by_user($user) && has_capability('mod/forum:exportownpost', $context, $user)));
    }
1331320
public function view(User $user, Page $page)
    {

        if ($user->canDo('page.page.view')) {
            return true;
        }

        return $user->id == $page->user_id;
    }
580094
protected function check_delete_permission( $post ) {
		$post_type = get_post_type_object( $post->post_type );

		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
			return false;
		}

		return current_user_can( $post_type->cap->delete_post, $post->ID );
	}
1314473
private function userAttemptBruteForceLockHasExceeded(User $user)
    {
        if ($user->login_attempt_lock_expiration > time()) {
            $user->updateAttributes(['login_attempt' => 0]);
            
            return true;
        }
        
        return false;
    }