Determine if the given user can update the given category.

@param UserPolicy $user
@param Category $category

@return bool
324847
public function update(UserPolicy $user, Category $category)
    {
        if ($user->canDo('blog.category.edit') && $user->isAdmin()) {
            return true;
        }

        return $category->user_id == user_id() && $category->user_type == user_type();
    }
1049924
public function updateUser(User $user)
    {
        try {
            return $this->innerGateway->updateUser($user);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
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;
    }
560683
public function update(User $user, Content $content)
    {
        if ($content->author->id === $user->id) {
            return true;
        }
        return $user->hasPermission('content-update');
    }
1185582
public function view(UserPolicy $user, Blog $blog)
    {
        if ($user->canDo('blog.blog.view') && $user->isAdmin()) {
            return true;
        }

        return $blog->user_id == user_id() && $blog->user_type == user_type();
    }
692719
public static function JoinUserData(&$Categories, $AddUserCategory = TRUE) {
      $IDs = array_keys($Categories);
      $DoHeadings = C('Vanilla.Categories.DoHeadings');
      
      if ($AddUserCategory) {
         $SQL = clone Gdn::SQL();
         $SQL->Reset();
         
         if (Gdn::Session()->UserID) {
            $Key = 'UserCategory_'.Gdn::Session()->UserID;
            $UserData = Gdn::Cache()->Get($Key);
            if ($UserData === Gdn_Cache::CACHEOP_FAILURE) {
               $UserData = $SQL->GetWhere('UserCategory', array('UserID' => Gdn::Session()->UserID))->ResultArray();
               $UserData = Gdn_DataSet::Index($UserData, 'CategoryID');
               Gdn::Cache()->Store($Key, $UserData);
            }
         } else
            $UserData = array();
         
//         Gdn::Controller()->SetData('UserData', $UserData);
         
         foreach ($IDs as $ID) {
            $Category = $Categories[$ID];
            
            $DateMarkedRead = GetValue('DateMarkedRead', $Category);
            $Row = GetValue($ID, $UserData);
            if ($Row) {
               $UserDateMarkedRead = $Row['DateMarkedRead'];
               
               if (!$DateMarkedRead || ($UserDateMarkedRead && Gdn_Format::ToTimestamp($UserDateMarkedRead) > Gdn_Format::ToTimestamp($DateMarkedRead))) {
                  $Categories[$ID]['DateMarkedRead'] = $UserDateMarkedRead;
                  $DateMarkedRead = $UserDateMarkedRead;
               }
               
               $Categories[$ID]['Unfollow'] = $Row['Unfollow'];
            } else {
               $Categories[$ID]['Unfollow'] = FALSE;
            }
            
            // Calculate the following field.
            $Following = !((bool)GetValue('Archived', $Category) || (bool)GetValue('Unfollow', $Row, FALSE));
            $Categories[$ID]['Following'] = $Following;

            // Calculate the read field.
            if ($DoHeadings && $Category['Depth'] <= 1) {
               $Categories[$ID]['Read'] = FALSE;
            } elseif ($DateMarkedRead) {
               if (GetValue('LastDateInserted', $Category))
                  $Categories[$ID]['Read'] = Gdn_Format::ToTimestamp($DateMarkedRead) >= Gdn_Format::ToTimestamp($Category['LastDateInserted']);
               else
                  $Categories[$ID]['Read'] = TRUE;
            } else {
               $Categories[$ID]['Read'] = FALSE;
            }
         }
         
      }
      
      // Add permissions.
      $Session = Gdn::Session();
      foreach ($IDs as $CID) {
         $Category = $Categories[$CID];
         $Categories[$CID]['PermsDiscussionsView'] = $Session->CheckPermission('Vanilla.Discussions.View', TRUE, 'Category', $Category['PermissionCategoryID']);
         $Categories[$CID]['PermsDiscussionsAdd'] = $Session->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', $Category['PermissionCategoryID']);
         $Categories[$CID]['PermsDiscussionsEdit'] = $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $Category['PermissionCategoryID']);
         $Categories[$CID]['PermsCommentsAdd'] = $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $Category['PermissionCategoryID']);
      }
   }
1153624
public function update(UserRequest $request, User $user)
    {
        $user->update($request->all());
        $this->_syncUserGroups($user, $request->get('user_group_id'));
        return redirect()->route('admin.user.index');
    }
632424
public function view(UserPolicy $user, Portfolio $portfolio)
    {
        if ($user->canDo('portfolio.portfolio.view') && $user->isAdmin()) {
            return true;
        }

        return $portfolio->user_id == user_id() && $portfolio->user_type == user_type();
    }
592643
public function update( models\VPN\Server\User $user){
        $rest = $this->getService( self::API_VPN_USER . $user->getLogin());
        $rest->PUT( $user);

        return $rest->getResult( models\VPN\Server\User::class);
    }
794068
public function edit(User $user, Role $role)
    {
        $this->authorize(UsersPolicy::PERMISSION_UPDATE);

        $user->load(['roles', 'roles.permissions']);
        $roles = $role->all();

        $this->setTitle($title = trans('auth::users.titles.edit-user'));
        $this->addBreadcrumb($title);

        return $this->view('admin.users.edit', compact('user', 'roles'));
    }
140703
public function view(UserPolicy $user, Faq $faq)
    {
        if ($user->canDo('faq.faq.view') && $user->isAdmin()) {
            return true;
        }

        return $faq->user_id == user_id() && $faq->user_type == user_type();
    }
563946
public function updateUserViewedCategory($categoryId = '')
    {
        $sessionUserViewedCategoryId = self::SESSION_ID_USER_VIEW_TOTAL_POST_BY_CATEGORY_FROM_SESSION . $categoryId;
        $this->logger->debug(__FUNCTION__, '$sessionUserViewedCategoryId => ' . json_encode($sessionUserViewedCategoryId));
        $checkSessionUserViewedCategoryValue = $this->hasSessionData($sessionUserViewedCategoryId);
        $this->logger->debug(__FUNCTION__, '$checkSessionUserViewedCategoryValue => ' . json_encode($checkSessionUserViewedCategoryValue));
        if ($checkSessionUserViewedCategoryValue === TRUE) {
            $currentSessionUserViewedCategoryValue = $this->getSessionData($sessionUserViewedCategoryId);
            $this->logger->debug(__FUNCTION__, '$currentSessionUserViewedCategoryValue => ' . json_encode($currentSessionUserViewedCategoryValue));
            if (is_numeric($currentSessionUserViewedCategoryValue)) {
                $viewValue = $currentSessionUserViewedCategoryValue + 1;
            } else {
                $viewValue = 1;
            }
            $this->logger->debug(__FUNCTION__, 'Update Total View Value: ' . $viewValue);
            $this->saveSessionData($sessionUserViewedCategoryId, $viewValue);
        } else {
            $this->saveSessionData($sessionUserViewedCategoryId, 1);
        }
    }
930036
protected function getCallbackStatus(User $user): bool
    {
        $allCurrentNotificationFilter = $user->getBunqUser()->getNotificationFilters();

        /** @var NotificationFilter $filter */
        foreach ($allCurrentNotificationFilter as $filter) {
            if (
                self::NOTIFICATION_CATEGORY_MUTATION === $filter->getCategory()
                && self::NOTIFICATION_DELIVERY_METHOD_URL === $filter->getNotificationDeliveryMethod()
                && $filter->getNotificationTarget() === $this->getUrl()
            ) {
                return true;
            }
        }

        return false;
    }
1227434
public function view(UserPolicy $user, Gallery $gallery)
    {
        if ($user->canDo('gallery.gallery.view') && $user->isAdmin()) {
            return true;
        }

        return $gallery->user_id == user_id() && $gallery->user_type == user_type();
    }
1232759
public static function can_view_category($category, $user = null) {
        if (!$category->id) {
            return has_capability('moodle/category:viewcourselist', context_system::instance(), $user);
        }
        $context = context_coursecat::instance($category->id);
        if (!$category->visible && !has_capability('moodle/category:viewhiddencategories', $context, $user)) {
            return false;
        }
        return has_capability('moodle/category:viewcourselist', $context, $user);
    }
357698
public function canUserAssignCategories()
    {
        $user = $this->getUser();

        return $user->isAdmin || \in_array('tl_news::categories', $user->alexf, true);
    }
1212391
public function update(CategoryRequest $request, Category $category)
    {
        $category->update($request->all());
        return new CategoryResource($category);
    }