@param Userinfo $userinfo
@param Userinfo $existinguser
@param          $overwrite

@return boolean return true if changed
962403
function doUpdateBlock(Userinfo $userinfo, Userinfo &$existinguser, $overwrite)
	{
		$changed = false;
		//check the blocked status
		if ($existinguser->block != $userinfo->block) {

			$update_block = $this->params->get('update_block', false);
			if ($update_block || $overwrite) {
				if ($userinfo->block) {
					//block the user
					try {
						$this->blockUser($userinfo, $existinguser);
						$changed = true;
					} catch (Exception $e) {
						$this->debugger->addError(Text::_('BLOCK_UPDATE_ERROR') . ' ' . $e->getMessage());
					}
					$changed = true;
				} else {
					//unblock the user
					try {
						$this->unblockUser($userinfo, $existinguser);
						$changed = true;
					} catch (Exception $e) {
						$this->debugger->addError(Text::_('BLOCK_UPDATE_ERROR') . ' ' . $e->getMessage());
					}
				}
			} else {
				//return a debug to inform we skipped this step
				$this->debugger->addDebug(Text::_('SKIPPED_BLOCK_UPDATE') . ': ' . $existinguser->block . ' -> ' . $userinfo->block);
			}
		}
		return $changed;
	}
763036
protected function add(Permission $permission, $override = true)
    {
        if ($override || ! $this->permissions->containsKey($permission->getName()))
        {
            $this->permissions->set($permission->getName(), $permission);
        }
    }
1357918
public function writeFile($overwrite = false) {
		$overwrite = ($this->type == self::TYPE_ENTITY) ? false : $overwrite;
		if (($this->existsFile() < self::FILE_MATCH) || $overwrite) {
			//$checkPath = dirname($this->getPath());
			if (@file_put_contents($this->getPath(), $this->getCode(), LOCK_EX)) {
				@chmod($this->getPath(), 0666);
				return true;
			}/* else {
				throw new Exception\PermissionException('Write access to Entity OR Model dirs denied');
			}*/
		}
		return false;
	}
533134
public function addUserData(array $data = [], $reset = false, $override = false) {
        if ($data && is_array($data)) {
            if ($override) {
                $data = array_diff_key($data, $_REQUEST);
            }
            if ($reset) {
                $this->userData = $data;
            } else {
                $this->userData = array_merge($this->userData, $data);
            }
        }
    }
484029
public static function delete_data_for_users(approved_userlist $userlist) {
        $context = $userlist->get_context();

        if ($context instanceof \context_user) {
            static::delete_data($context->instanceid);
        }
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
364976
public static function userCan(int $user_id, string $role, string $permission, $callback = null) : bool
    {
        return (new Services\UsersService)
            ->userCan($user_id, $role, $permission, $callback);
    }
632727
protected function get_post_author($userid, $course, $forum, $cm, $context) {
        if (!isset($this->users[$userid])) {
            // This user no longer exists.
            return false;
        }

        $user = $this->users[$userid];

        if (!isset($user->groups)) {
            // Initialise the groups list.
            $user->groups = [];
        }

        if (!isset($user->groups[$forum->id])) {
            $user->groups[$forum->id] = groups_get_all_groups($course->id, $user->id, $cm->groupingid);
        }

        // Clone the user object to prevent leaks between messages.
        return (object) (array) $user;
    }
1177399
public function setConfig(array $config, $overwrite = false)
    {
        if ($overwrite) {
            $this->config = $this->mergeConfig($this->config, $config);
        } else {
            $this->config = $this->mergeConfig($config, $this->config);
        }
    }
805356
public function exceedsLimit($user_id, $store_id)
    {
        if ($this->user->isSuperadmin($user_id)) {
            return false; // No limits for superadmin
        }

        $limit = $this->getLimit($user_id);

        if (empty($limit)) {
            return false;
        }

        $conditions = array(
            'user_id' => $user_id,
            'store_id' => $store_id
        );

        $existing = $this->getList($conditions);
        return count($existing) > $limit;
    }
265143
public function updateUserContext(UserContext $context): void
    {
        $context->addParameter(
            'userId',
            $this->repository->getPermissionResolver()->getCurrentUserReference()->getUserId()
        );
    }
802655
public function isWritableByCurrentUser()
    {
        if (isset($this->hasWritePermission)) {
            return $this->hasWritePermission;
        }

        // performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB.
        $this->hasWritePermission = Piwik::isUserHasSomeViewAccess();

        return $this->hasWritePermission;
    }
1316820
public function Merge($OldUserID, $NewUserID) {
      $OldUser = $this->GetID($OldUserID, DATASET_TYPE_ARRAY);
      $NewUser = $this->GetID($NewUserID, DATASET_TYPE_ARRAY);
      
      if (!$OldUser || !$NewUser) {
         throw new Gdn_UserException("Could not find one or both users to merge.");
      }
      
      $Map = array('UserID', 'Name', 'Email', 'CountVisits', 'CountDiscussions', 'CountComments');
      
      $Result = array('MergeID' => NULL, 'Before' => array(
         'OldUser' => ArrayTranslate($OldUser, $Map),
         'NewUser' => ArrayTranslate($NewUser, $Map)));
      
      // Start the merge.
      $MergeID = $this->MergeStart($OldUserID, $NewUserID);
      
      // Copy all discussions from the old user to the new user.
      $this->MergeCopy($MergeID, 'Discussion', 'InsertUserID', $OldUserID, $NewUserID);
      
      // Copy all the comments from the old user to the new user.
      $this->MergeCopy($MergeID, 'Comment', 'InsertUserID', $OldUserID, $NewUserID);
      
      // Copy all of the activities.
      $this->MergeCopy($MergeID, 'Activity', 'NotifyUserID', $OldUserID, $NewUserID);
      $this->MergeCopy($MergeID, 'Activity', 'InsertUserID', $OldUserID, $NewUserID);
      $this->MergeCopy($MergeID, 'Activity', 'ActivityUserID', $OldUserID, $NewUserID);
      
      // Copy all of the activity comments.
      $this->MergeCopy($MergeID, 'ActivityComment', 'InsertUserID', $OldUserID, $NewUserID);
      
      // Copy all conversations.
      $this->MergeCopy($MergeID, 'Conversation', 'InsertUserID', $OldUserID, $NewUserID);
      $this->MergeCopy($MergeID, 'ConversationMessage', 'InsertUserID', $OldUserID, $NewUserID, 'MessageID');
      $this->MergeCopy($MergeID, 'UserConversation', 'UserID', $OldUserID, $NewUserID, 'ConversationID');
      
      $this->MergeFinish($MergeID);
      
      $OldUser = $this->GetID($OldUserID, DATASET_TYPE_ARRAY);
      $NewUser = $this->GetID($NewUserID, DATASET_TYPE_ARRAY);
      
      $Result['MergeID'] = $MergeID;
      $Result['After'] = array(
         'OldUser' => ArrayTranslate($OldUser, $Map),
         'NewUser' => ArrayTranslate($NewUser, $Map));
      
      return $Result;
   }
737741
private boolean renameOverwrite(String oldname, String newname) {

        boolean deleted = delete(newname);

        if (exists(oldname)) {
            File file = new File(oldname);

            return file.renameTo(new File(newname));
        }

        return deleted;
    }
1216392
private function set_userinfo($iuserinfo)
    {
        if ($iuserinfo === null)
        {
            $this->iuserinfo = null;
        }
        else
        {
            $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:');
            $this->scheme_normalization();
        }

        return true;
    }
1086736
public static function get_users_in_context(userlist $userlist) {
        $context = $userlist->get_context();

        if (!$context instanceof \context_user) {
            return;
        }

        // The data is associated at the user context level, so retrieve the user's context id.
        $sql = "SELECT usermodified AS userid
                  FROM {repository_onedrive_access}
                 WHERE usermodified = ?";
        $params = [$context->instanceid];
        $userlist->add_from_sql('userid', $sql, $params);
    }
293124
public function isOnline(int $user_id): bool
    {
        if (isset($this->_online_status_cached[$user_id])) {
            return $this->_online_status_cached[$user_id];
        }

        // Check session for current user exists
        $sessions = new UsersSessionEntityRepository();
        $sessions->setWhereUserId($user_id);
        $sessions->setLimit(1);
        $sessions->addWhereFieldIsHigher('ts', (NOW - 120)); // 2 minutes

        return $this->_online_status_cached[$user_id] = $sessions->hasAnyObjectInCollection();
    }