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

@throws RuntimeException
@return boolean return true if changed
16944
function doUpdateEmail(Userinfo $userinfo, Userinfo &$existinguser, $overwrite)
	{
		$changed = false;

		if (strtolower($existinguser->email) != strtolower($userinfo->email)) {
			$this->debugger->addDebug(Text::_('EMAIL_CONFLICT'));
			$update_email = $this->params->get('update_email', false);
			if ($update_email || $overwrite) {
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_ENABLED'));
				try {
					$this->updateEmail($userinfo, $existinguser);
					$changed = true;
				} catch (Exception $e) {
					$this->debugger->addError(Text::_('EMAIL_UPDATE_ERROR') . ' ' . $e->getMessage());
				}
			} else {
				//return a email conflict
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_DISABLED'));

				$this->debugger->set('userinfo', $existinguser);
				throw new RuntimeException(Text::_('EMAIL') . ' ' . Text::_('CONFLICT') . ': ' . $existinguser->email . ' -> ' . $userinfo->email);
			}
		}
		return $changed;
	}
395534
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.
        if ($this->hasSiteBeenCreated()) {
            $this->hasWritePermission = Piwik::isUserHasAdminAccess($this->idSite);
        } else {
            $this->hasWritePermission = Piwik::hasUserSuperUserAccess();
        }

        return $this->hasWritePermission;
    }
409927
public function UpdateUser($UserID, $Inc = FALSE) {
      if ($Inc) {
         // Just increment the comment count.
         $this->SQL
            ->Update('User')
            ->Set('CountComments', 'CountComments + 1', FALSE)
            ->Where('UserID', $UserID)
            ->Put();
      } else {
         // Retrieve a comment count
         $CountComments = $this->SQL
            ->Select('c.CommentID', 'count', 'CountComments')
            ->From('Comment c')
            ->Where('c.InsertUserID', $UserID)
            ->Get()
            ->FirstRow()
            ->CountComments;

         // Save to the attributes column of the user table for this user.
         Gdn::UserModel()->SetField($UserID, 'CountComments', $CountComments);
      }
   }
268635
public function save(Userinfo $userinfo, Userinfo $olduserinfo = null, $new = false)
	{
		$this->debugger->set(null, array());

		//create an array to store the debug info
		$debug_info = array();
		$error_info = array();


		$plugins = Factory::getPlugins();

		if ($userinfo instanceof Userinfo) {
			// Recover the old data of the user
			// This is then used to determine if the username was changed
			$updateUsername = false;

			if ($userinfo->getJname() !== null && $olduserinfo->getJname() !== null) {
				if ($new == false && $userinfo instanceof Userinfo && $olduserinfo instanceof Userinfo) {
					if ($userinfo->getJname() == $olduserinfo->getJname() && $userinfo->username != $olduserinfo->username) {
						$updateUsername = true;
					}
				}
			}
			$exsistingUser = User::search($olduserinfo, true);

			foreach ($plugins as $plugin) {
				try {
					$userPlugin = Factory::getUser($plugin->name);
					if ($userPlugin->validateUser($userinfo)) {
						if ($updateUsername) {
							if ($exsistingUser instanceof Userinfo) {
								$pluginUserinfo = $userPlugin->getUser($exsistingUser);

								if ($pluginUserinfo instanceof Userinfo) {
									try {
										$userPlugin->resetDebugger();
										$userPlugin->updateUsername($userinfo, $pluginUserinfo);
										if (!$userPlugin->debugger->isEmpty('error')) {
											$error_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('ERROR') ] = $userPlugin->debugger->get('error');
										}
										if (!$userPlugin->debugger->isEmpty('debug')) {
											$debug_info[$plugin->name . ' ' . Text::_('USERNAME') . ' ' . Text::_('UPDATE') . ' ' . Text::_('DEBUG') ] = $userPlugin->debugger->get('debug');
										}
									} catch (Exception $e) {
										$status[LogLevel::ERROR][] = Text::_('USERNAME_UPDATE_ERROR') . ': ' . $e->getMessage();
									}
								} else {
									$error_info[$plugin->name] = Text::_('NO_USER_DATA_FOUND');
								}
							}
						}
						//run the update user to ensure any other userinfo is updated as well
						$userPlugin->resetDebugger();
						$pluginUserinfo = $userPlugin->updateUser($userinfo, 1);
						$debug = $userPlugin->debugger->get();

						if (!empty($debug[LogLevel::ERROR])) {
							$error_info[$plugin->name] = $debug[LogLevel::ERROR];
						}
						if (!empty($debug[LogLevel::DEBUG])) {
							$debug_info[$plugin->name] = $debug[LogLevel::DEBUG];
						}
						if (!$pluginUserinfo instanceof Userinfo) {
							//make sure the userinfo is available
							$pluginUserinfo = $userPlugin->getUser($userinfo);
						}
						//update the jfusion_users table
						if ($pluginUserinfo instanceof Userinfo) {
							$userPlugin->updateLookup($pluginUserinfo, $userinfo);
						}
					}
				} catch (Exception $e) {
					$error_info[$plugin->name] = array($e->getMessage());
				}
			}
		}
		$this->debugger->set('debug', $debug_info);
		$this->debugger->set('error', $error_info);
		return true;
	}
563064
public function setOwner( $userName )
	{
		if( !$userName )
			throw new InvalidArgumentException( 'No User Name given.' );
		if( !file_exists( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
#		if( !$this->isOwner() )
#			throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' );
		if( !$this->isWritable( $this->fileName ) )
			throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
		if( !@chOwn( $this->fileName, $userName ) )
			throw new RuntimeException( 'Only a superuser can change file owner' );
	}
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);
    }
369259
public function updateUser($userId, Request $request)
    {
        $user = $this->userService->loadUser($userId);

        $updateStruct = $this->inputDispatcher->parse(
            new Message(
                array(
                    'Content-Type' => $request->headers->get('Content-Type'),
                    // @todo Needs refactoring! Temporary solution so parser has access to URL
                    'Url' => $request->getPathInfo(),
                ),
                $request->getContent()
            )
        );

        if ($updateStruct->sectionId !== null) {
            $section = $this->sectionService->loadSection($updateStruct->sectionId);
            $this->sectionService->assignSection(
                $user->getVersionInfo()->getContentInfo(),
                $section
            );
        }

        $updatedUser = $this->userService->updateUser($user, $updateStruct->userUpdateStruct);
        $updatedContentInfo = $updatedUser->getVersionInfo()->getContentInfo();
        $mainLocation = $this->locationService->loadLocation($updatedContentInfo->mainLocationId);
        $contentType = $this->contentTypeService->loadContentType($updatedContentInfo->contentTypeId);

        return new Values\RestUser(
            $updatedUser,
            $contentType,
            $updatedContentInfo,
            $mainLocation,
            $this->contentService->loadRelations($updatedUser->getVersionInfo())
        );
    }
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);
        }
    }
560737
public function load($overwrite = false, $cache = true)
	{
		$config = array();

		// try to retrieve the config from the database
		try
		{
			$result = \DB::select('config')->from($this->table)->where('identifier', '=', $this->identifier)->execute();
		}
		catch (Database_Exception $e)
		{
			// strip the actual query from the message
			$msg = $e->getMessage();
			$msg = substr($msg, 0, strlen($msg)  - strlen(strrchr($msg, ':')));

			// and rethrow it
			throw new \Database_Exception($msg);
		}

		// did we succeed?
		if ($result->count())
		{
			empty($result[0]['config']) or $config = unserialize($this->parse_vars($result[0]['config']));
		}

		return $config;
	}
1013480
public static function search(Userinfo $userinfo, $lookup = false)
	{
		$exsistingUser = null;

		if ($lookup && $userinfo->getJname() !== null) {
			$userPlugin = Factory::getUser($userinfo->getJname());

			$exsistingUser = $userPlugin->lookupUser($userinfo);
		}
		if (!$exsistingUser instanceof Userinfo) {
			$plugins = Factory::getPlugins();
			foreach ($plugins as $plugin) {
				try {
					$JFusionSlave = Factory::getUser($plugin->name);

					$exsistingUser = $JFusionSlave->getUser($userinfo);
					if ($exsistingUser instanceof Userinfo) {
						break;
					}
				} catch (Exception $e) {
				}
			}
		}
		return $exsistingUser;
	}
1292585
public function setConfig(array $config, $overwrite = false) 
    {
        if ($overwrite) {
            $this->config = $this->_mergeConfig($this->config, $config);
        } else {
            $this->config = $this->_mergeConfig($config, $this->config);
        }
    }
1169410
public function update(User $user, File $file)
    {
        if ($file->author_id === $user->id) {
            return true;
        }
        return $user->hasPermission('file-update');
    }
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;
    }
847279
public static function delete_data_for_users(approved_userlist $userlist) {
        $context = $userlist->get_context();

        if (!in_array($context->instanceid, $userlist->get_userids())) {
            return;
        }

        if ($context->contextlevel == CONTEXT_USER) {
            // We can only delete our own data in the user context, nothing in course or system.
            static::delete_user_data($context->instanceid);
        }
    }
502032
public function addValue($key, $value, $overwrite = false)
    {
        if (!isset($this->data[$key]) || $overwrite) {
            $this->data[$key] = (string) $value;
        }
    }
296583
function updateUserDataField(userId, data, overwrite, callback) {
        return _updateUserObjectField(userId, ['data'], data, overwrite)
            .then(function (userData) {
                return userData.data;
            })
            .nodeify(callback);
    }
922505
public function addReference($identifier, $value, $overwrite = false)
    {
        foreach ($this->resolvers as $resolver) {
            if ($resolver instanceof ReferenceBagInterface) {
                if ($resolver->addReference($identifier, $value, $overwrite)) {
                    return true;
                }
            }
        }

        return false;
    }