Lock the user for an action.

@param integer $userId
@param string $table
@param string $pk
@param string $translation
@param array $translationArgs
558928
public static function lock($userId, $table, $pk, $translation, array $translationArgs = [])
    {
        $model = self::findOne(['user_id' => $userId]);
        
        if ($model) {
            $model->updateAttributes([
                'last_timestamp' => time(),
                'lock_table' => $table,
                'lock_pk' => $pk,
                'lock_translation' => $translation,
                'lock_translation_args' => Json::encode($translationArgs),
            ]);
        }
    }
144110
public void actionUnlockUser() throws Exception {

        CmsUUID userId = new CmsUUID(m_paramUserId);
        CmsObject cms = getCms();
        CmsUser user = cms.readUser(userId);
        OpenCms.getLoginManager().unlockUser(getCms(), user);
        actionCloseDialog();
    }
326575
public void setIsolation(int level) {

        if (isInMidTransaction()) {
            throw Error.error(ErrorCode.X_25001);
        }

        if (level == SessionInterface.TX_READ_UNCOMMITTED) {
            isReadOnly = true;
        }

        isolationMode = level;

        if (isolationMode != isolationModeDefault) {
            database.logger.writeToLog(this, getTransactionIsolationSQL());
        }
    }
1193761
public function lockTable($table)
	{
		$query = $this->getQuery(true);

		$this->setQuery('LOCK TABLES ' . $this->quoteName($table) . ' WRITE');

		$this->setQuery($query)->execute();

		return $this;
	}
882285
protected static function delete_user_data($userid) {
        global $DB;
        $DB->delete_records_select('messageinbound_messagelist', 'userid = :userid', ['userid' => $userid]);
        \core_userkey\privacy\provider::delete_userkeys('messageinbound_handler', $userid);
    }
152941
protected function forceLogoutForUserById($userId) {
		$this->deleteRememberDirectiveForUserById($userId);
		$this->db->exec(
			'UPDATE ' . $this->makeTableName('users') . ' SET force_logout = force_logout + 1 WHERE id = ?',
			[ $userId ]
		);
	}
918675
function RowLock($tables,$where,$col=false)
	{
		if ($this->autoCommit) {
			$this->BeginTrans();
		}
		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
		return 1;
	}
206164
public function deleteUser($userId)
    {
        $query = $this->handler->createDeleteQuery();
        $query
            ->deleteFrom($this->handler->quoteTable('ezuser_setting'))
            ->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('user_id'),
                    $query->bindValue($userId, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();

        $query = $this->handler->createDeleteQuery();
        $query
            ->deleteFrom($this->handler->quoteTable('ezuser'))
            ->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('contentobject_id'),
                    $query->bindValue($userId, null, \PDO::PARAM_INT)
                )
            );
        $query->prepare()->execute();
    }
1308960
public void lock(String statement, Object parameter) {
    // do not perform locking if H2 database is used. H2 uses table level locks
    // by default which may cause deadlocks if the deploy command needs to get a new
    // Id using the DbIdGenerator while performing a deployment.
    if (!DbSqlSessionFactory.H2.equals(dbSqlSessionFactory.getDatabaseType())) {
      String mappedStatement = dbSqlSessionFactory.mapStatement(statement);
      if (!Context.getProcessEngineConfiguration().isJdbcBatchProcessing()) {
        sqlSession.update(mappedStatement, parameter);
      } else {
        sqlSession.selectList(mappedStatement, parameter);
      }
    }
  }
1355099
function RowLock($tables,$where,$col='top 1 null as ignore')
	{
		if (!$this->_hastrans) $this->BeginTrans();
		$tables = str_replace(',',' HOLDLOCK,',$tables);
		return $this->GetOne("select $col from $tables HOLDLOCK where $where");

	}
175004
public function insert($table, array $row, $pkval=false)
    {
    	$ds = $this->ds();
		list($holders, $values) = SqlHelper::placeholder($row);
        $holders = implode(',', $holders);
        
        $fields = SqlHelper::qfields(array_keys($values));        
        $table = SqlHelper::qtable($table);
		
        $result = Sql::write($ds, Sql::MODE_WRITE_INSERT, [
				SqlHelper::bind($ds, "INSERT INTO {$table} ({$fields}) VALUES ({$holders})", $row),
				$pkval
			]);
		return $result;
	}
77276
public function Delete($UserID = '', $Method = '') {
      $this->Permission('Garden.Users.Delete');
      $Session = Gdn::Session();
      if($Session->User->UserID == $UserID)
         trigger_error(ErrorMessage("You cannot delete the user you are logged in as.", $this->ClassName, 'FetchViewLocation'), E_USER_ERROR);
      $this->AddSideMenu('dashboard/user');
      $this->Title(T('Delete User'));

      $RoleModel = new RoleModel();
      $AllRoles = $RoleModel->GetArray();
      
      // By default, people with access here can freely assign all roles
      $this->RoleData = $AllRoles;
      
      $UserModel = new UserModel();
      $this->User = $UserModel->GetID($UserID);
      
      try {
         
         $CanDelete = TRUE;
         $this->EventArguments['CanDelete'] = &$CanDelete;
         $this->EventArguments['TargetUser'] = &$this->User;
         
         // These are all the 'effective' roles for this delete action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] = &$this->RoleData;
         
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $this->UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] = &$this->UserRoleData;
         
         $this->FireEvent("BeforeUserDelete");
         $this->SetData('CanDelete', $CanDelete);
         
         $Method = in_array($Method, array('delete', 'keep', 'wipe')) ? $Method : '';
         $this->Method = $Method;
         if ($Method != '')
            $this->View = 'deleteconfirm';

         if ($this->Form->AuthenticatedPostBack() && $Method != '') {
            $UserModel->Delete($UserID, array('DeleteMethod' => $Method));
            $this->View = 'deletecomplete';
         }

      } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
      }
      $this->Render();
   }
772384
public static function lock_submissions($assignmentid, $userids) {
        global $CFG;

        $params = self::validate_parameters(self::lock_submissions_parameters(),
                        array('assignmentid' => $assignmentid,
                              'userids' => $userids));

        list($assignment, $course, $cm, $context) = self::validate_assign($params['assignmentid']);

        $warnings = array();
        foreach ($params['userids'] as $userid) {
            if (!$assignment->lock_submission($userid)) {
                $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['assignmentid'];
                $warnings[] = self::generate_warning($params['assignmentid'],
                                                     'couldnotlock',
                                                     $detail);
            }
        }

        return $warnings;
    }
74272
function addForeignKey($table, $pkname, $tables)
	{
		if ( is_string($tables) )
			$tables = array($tables);
			
		
		$this->_foreignKeys[$table] = array(
					'primaryKey' => $pkname,
					'tables' => $tables
				);
	}
231114
public static function unlock_submissions($assignmentid, $userids) {
        global $CFG;

        $params = self::validate_parameters(self::unlock_submissions_parameters(),
                        array('assignmentid' => $assignmentid,
                              'userids' => $userids));

        list($assignment, $course, $cm, $context) = self::validate_assign($params['assignmentid']);

        $warnings = array();
        foreach ($params['userids'] as $userid) {
            if (!$assignment->unlock_submission($userid)) {
                $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['assignmentid'];
                $warnings[] = self::generate_warning($params['assignmentid'],
                                                     'couldnotunlock',
                                                     $detail);
            }
        }

        return $warnings;
    }
688158
function enforce($Permission, $UserID = null)
	{
	if ($UserID === null)
                throw new \RbacUserNotProvidedException ("\$UserID is a required argument.");

		if (! $this->check($Permission, $UserID)) {
            header('HTTP/1.1 403 Forbidden');
            die("<strong>Forbidden</strong>: You do not have permission to access this resource.");
        }

        return true;
	}
1135728
protected function approveTranslation($access, TranslationEntity $translation, UserEntity $user, $packageVersionID)
    {
        if ($access < Access::ADMIN) {
            throw new UserMessageException(t('Access denied'));
        }
        if ($translation->isCurrent()) {
            throw new UserMessageException(t('The selected translation is already the current one'));
        }
        $translationID = $translation->getID();
        $translations = $this->convertTranslationToGettext($translation, false);
        $importer = $this->app->make(Importer::class);
        $importer->import($translations, $translation->getLocale(), $user, ImportOptions::forAdministrators());
        $this->getEntityManager()->clear();
        $translation = $this->app->make(TranslationRepository::class)->find($translationID);
        $result = $this->app->make(Editor::class)->getTranslations($translation->getLocale(), $translation->getTranslatable());

        return $this->app->make(ResponseFactoryInterface::class)->json($result);
    }