Imports user. Returns import status.

@param array $data db row array

@throws Exception If user exists with provided OXID, throw an exception.

@return string $oxid on success, bool FALSE on failure
972810
public function import($data)
    {
        if (isset($data['OXUSERNAME'])) {
            $id = $data['OXID'];
            $userName = $data['OXUSERNAME'];

            $user = oxNew(\OxidEsales\Eshop\Application\Model\User::class, "core");
            $user->oxuser__oxusername = new \OxidEsales\Eshop\Core\Field($userName, \OxidEsales\Eshop\Core\Field::T_RAW);

            if ($user->exists($id) && $id != $user->getId()) {
                throw new Exception("USER $userName already exists!");
            }
        }

        return parent::import($data);
    }
874011
public function batchInviteUser(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_TAG_USERS_DELETE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result['jobid'] : $this->dump($result);
    }
918245
public function save($data=array())
    {

		if (empty($data)) {
			throw new \Exception( "User data is missing" );
		}
        $data = (object) $data;

		if ((!isset($data->email) || empty($data->email))) {
			throw new \Exception( "Email is required" );
		}
		if ((!isset($data->password) || empty($data->password)) && !isset($data->id)) {
			throw new \Exception( "Password is required" );
		}

		$new  = false;
		if (isset($data->id)) {
			$entity = $this->getById($data->id);
		} else {
			$entity = new entity();
			$new    = true;
		}
		if (isset($data->name)) {
			$entity->setName($data->name);
		}
		if (isset($data->email)) {
			$entity->setEmail($data->email);
		}
		if (isset($data->password)) {
			$entity->setPassword($this->getSalted($data->password));
		} elseif (isset($data->new_password)){
			$entity->setPassword($this->getSalted($data->new_password));
		}
		if (empty($data->role)) {
			$data->role = $this->_getDefaultRole();
		}
		$entity->setRole($data->role);
		if (isset($data->gateway_customer_id)) {
			$entity->setGatewayCustomerId($data->gateway_customer_id);
		}

		if ($new) {
			$this->_em->persist($entity);
		} else {
			$this->_em->merge($entity);
		}

		// Save the entity
		try {
			$eventType = $new ? Log::EVENT_CREATE : Log::EVENT_UPDATE;
			if(isset($data->new_password)){
				$eventType = Log::EVENT_PASSWORD;
				unset($data->new_password);
			}
			unset($data->password);

			$this->createUserEventLog($eventType, $data);
			$this->_em->flush();
			$this->setEntity($entity);

			return $entity->getId();

		} catch ( \Doctrine\DBAL\Exception\UniqueConstraintViolationException $e ) {
			// \Erdiko::log(\Psr\Log\LogLevel::INFO, 'UniqueConstraintViolationException caught: '.$e->getMessage());
			throw new \Exception( "Can not create user with duplicate email" );
		}

		return null;
	}
811182
public function execute($data = null)
    {
        if (!isset($data->db) || !$data->db instanceof AbstractDatabaseDriver) {
            return $this->next->execute($data);
        }

        if ($data->debug) {
            $this->logger->log(LogLevel::DEBUG, 'Executed: {sql}', ['sql' => $data->sql]);
        }

        try {
            $result = $this->next->execute($data);
        } catch (\RuntimeException $e) {
            // Throw the normal query exception.
            $this->logger->log(
                LogLevel::ERROR,
                'Database query failed (error #{code}): {message}',
                ['code' => $e->getCode(), 'message' => $e->getMessage()]
            );

            throw new $e();
        }

        return $result;
    }
849295
public function import(string $id = '')
    {
        $table = TableRegistry::get('CsvMigrations.Imports');
        Assert::isInstanceOf($table, ImportsTable::class);

        $entity = '' === $id ? $table->newEntity() : $table->get($id);

        // AJAX logic
        if ($this->request->accepts('application/json')) { // Import/progress.ctp
            $this->viewBuilder()->setClassName('Json');
            $utility = new ImportUtility($this->{$this->name}, $this->request, $this->Flash);
            $columns = ['row_number', 'status', 'status_message'];
            $query = $utility->getImportResults($entity, $columns);
            Assert::isInstanceOf($query, Query::class);

            $pagination = [
                'count' => $query->count()
            ];

            $data = ImportUtility::toDatatables($this->paginate($query), $columns);
            $data = ImportUtility::actionButtons($this->paginate($query), $this->{$this->name}, $data);
            $data = ImportUtility::setStatusLabels($data, 1);

            $this->set([
                'success' => true,
                'data' => $data,
                'pagination' => $pagination,
                '_serialize' => ['success', 'data', 'pagination']
            ]);

            return;
        }

        // POST logic
        if ($this->request->is('post')) { // Import/upload.ctp
            $utility = new ImportUtility($this->{$this->name}, $this->request, $this->Flash);
            $filename = $utility->upload();
            if (!empty($filename) && $utility->create($table, $entity, $filename)) {
                return $this->redirect([$entity->id]);
            }
        }

        // PUT logic
        if ($this->request->is('put')) { // Import/mapping.ctp
            $options = ImportUtility::prepareOptions((array)$this->request->getData('options'));
            $entity = $table->patchEntity($entity, ['options' => $options]);
            if ($table->save($entity)) {
                return $this->redirect($this->request->getAttribute('here'));
            } else {
                $this->Flash->error('Unable to set import options.');
            }
        }

        // GET logic
        if (!$entity->isNew()) {
            $utility = new ImportUtility($this->{$this->name}, $this->request, $this->Flash);
            if (!$entity->get('options')) { // Import/mapping.ctp
                $this->set('headers', ImportUtility::getUploadHeaders($entity));
                $this->set('columns', $utility->getTableColumns());
            } else { // Import/progress.ctp
                $resultsTable = TableRegistry::get('CsvMigrations.ImportResults');
                $this->set('importCount', $resultsTable->find('imported', ['import' => $entity])->count());
                $this->set('pendingCount', $resultsTable->find('pending', ['import' => $entity])->count());
                $this->set('failCount', $resultsTable->find('failed', ['import' => $entity])->count());
            }
        } else { // Import/upload.ctp
            $query = $table->find('all')
                ->where(['model_name' => $this->{$this->name}->getRegistryAlias()])
                ->order(['created' => 'desc']);

            $this->set('existingImports', $query->all());
        }

        $this->set('import', $entity);

        if ($entity->isNew()) {
            $this->render('CsvMigrations.Import/upload');
        } else {
            if (!$entity->get('options')) {
                $this->render('CsvMigrations.Import/mapping');
            } else {
                $this->render('CsvMigrations.Import/progress');
            }
        }
    }
973790
protected function import($content, User $user, $format)
    {
        if (!isset($this->importers[$format])) {
            throw new \Exception(sprintf("No importer for the '%s' format.", $format));
        }

        return $this->importers[$format]->import($content, $user);
    }
1214057
public function batchSyncUser(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_USER_BATCH_SYNC_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result['jobid'] : $this->dump($result);
    }
34041
private function import(&$data)
    {
        $imports = array();
        preg_match_all('/#@([-a-z0-9\/_]+)\\n/is', $data, $imports, PREG_SET_ORDER);
        foreach ($imports as $import) {
            $importPath = FS2LANG . '/' . $this->local . '/' . $import[1] . '.txt';
            $importData = @file_get_contents($importPath);

            // getting file content ok
            if ($importData != false) {
                $importData = str_replace(array("\r\n", "\r"), "\n", $importData); // unify linebreaks
                $this->import($importData);
                $replace = '/#@' . preg_quote($import[1], '/') . '/i';
                $data = preg_replace($replace, $importData, $data);
                // replace all imports recursive
            }
        }
        unset($imports);
    }
233387
public function import(array $data)
    {
        $this->clearErrors();
        $result = true;

        foreach ($data as $section) {
            if ($this->importItem($section) === false) {
                $result = false;
            }
        }

        return $result;
    }
1205007
protected function createObjectFromData(array $data) {
    // determine if we are loading or creating
    $createFromLoadedData = (sizeof($data) > 0) ? true : false;

    // initialize data and oid
    $oid = null;
    $initialData = $data;
    if ($createFromLoadedData) {
      $oid = $this->constructOID($initialData);
      // cleanup data
      foreach($initialData as $name => $value) {
        if ($this->hasAttribute($name) || strpos($name, self::INTERNAL_VALUE_PREFIX) === 0) {
          $value = $this->convertValueFromStorage($name, $value);
          $initialData[$name] = $value;
        }
        else {
          unset($initialData[$name]);
        }
      }
    }

    // construct object
    $object = $this->createObject($oid, $initialData);
    return $object;
  }
1370835
public function import(array $users = []) : int
    {
        $imported = 0;

        $this->output->progressStart(count($users));

        foreach ($users as $user) {
            try {
                // Import the user and retrieve it's model.
                $model = Bus::dispatch(
                    new ImportUser($user, $this->model())
                );

                // Set the users password.
                Bus::dispatch(new SyncPassword($model));

                // Save the returned model.
                $this->save($user, $model);

                if ($this->isDeleting()) {
                    $this->delete($user, $model);
                }

                if ($this->isRestoring()) {
                    $this->restore($user, $model);
                }

                $imported++;
            } catch (Exception $e) {
                // Log the unsuccessful import.
                if ($this->isLogging()) {
                    logger()->error("Unable to import user {$user->getCommonName()}. {$e->getMessage()}");
                }
            }

            $this->output->progressAdvance();
        }

        $this->output->progressFinish();

        return $imported;
    }
596845
public function import(array $data)
    {
        $response = $this->client->post("{$this->uriImport}product/", [
            'json' => $data,
            'query' => [
                'key' => $this->config['data']['key'],
            ],
        ]);

        $response = json_decode($response->getBody(), true);

        if (isset($response['affected']) && $response['affected'] > 0) {
            return true;
        }

        return false;
    }
133966
public function request(array $data) {
    // Create request
    $request = Loader::request($this->config, $data);
    // Return response
    return Loader::response(
      // Execute
      $this->getHttp()->post($this->getRequestUrl(), (string) $request)->json
      // Attach request
    )->attach('request', $request);
  }
271500
public function getList(array $data = array())
    {
        $sql = 'SELECT b.*, u.name AS user_name';

        if (!empty($data['count'])) {
            $sql = 'SELECT COUNT(b.backup_id)';
        }

        $sql .= ' FROM backup b
                  LEFT JOIN user u ON(b.user_id = u.user_id)
                  WHERE b.backup_id > 0';

        $where = array();

        if (isset($data['user_id'])) {
            $sql .= ' AND b.user_id = ?';
            $where[] = $data['user_id'];
        }

        if (isset($data['id'])) {
            $sql .= ' AND b.id = ?';
            $where[] = $data['id'];
        }

        if (isset($data['version'])) {
            $sql .= ' AND b.version = ?';
            $where[] = $data['version'];
        }

        if (isset($data['name'])) {
            $sql .= ' AND b.name LIKE ?';
            $where[] = "%{$data['name']}%";
        }

        $allowed_order = array('asc', 'desc');
        $allowed_sort = array('name', 'user_id', 'version',
            'id', 'backup_id', 'type', 'created');

        if (isset($data['sort'])
            && in_array($data['sort'], $allowed_sort)
            && isset($data['order'])
            && in_array($data['order'], $allowed_order)
        ) {
            $sql .= " ORDER BY b.{$data['sort']} {$data['order']}";
        } else {
            $sql .= ' ORDER BY b.created DESC';
        }

        if (!empty($data['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $data['limit']));
        }

        if (!empty($data['count'])) {
            return (int) $this->db->fetchColumn($sql, $where);
        }

        $results = $this->db->fetchAll($sql, $where, array('index' => 'backup_id'));
        $this->hook->attach('module.backup.list', $results, $this);
        return $results;
    }
843220
protected function create(array $data)
    {
        $user = User::create([
            'uuid' => (string) Str::uuid(),
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);

        return $user;
    }
85971
public function import($data) {
		
		if (! is_array($data)) {
			$data = $this->makeArray($data);
		}
		
		foreach($data as $key => $value) {
			$this->set($key, $value);
		}
	}
210324
public function createUser($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        try {
            if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.EMAIL_EXISTS', '_An account with that email already exists');
                
                return $response;
            }
            
            
            //Create and write member
            $member=new Member();
            $member->FirstName=(!empty($data->firstname) ? $data->firstname:$data->username);
            $member->Surname=(!empty($data->surname) ? $data->surname:null);
            $member->Email=$data->username;
            $member->Password=$data->Password;
            $member->UseHeartbeat=0;
            
            if(!$member->validate()) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.PASSWORD_NOT_VALID', '_Password is not valid');
                
                return $response;
            }
            
            $member->write();
            
            
            $response['status']='HELO';
            $response['message']="User added successfully";
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }