Perform a bulk update of any number of user profiles from emails CSV
@param String $emails
@param Array $update
@param bool|String $report_email
@param bool|String $postback_url
@return array
191058
public function processUpdateJobFromEmails($emails, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
        return $this->processUpdateJob('emails', $emails, $update, $report_email, $postback_url, [ ], $options);
    }
564107
public function update($params)
    {
        if (is_array($params)) {
            $count_rows = count($params['columns']);
            $increment = 1;
            foreach ($params['columns'] as $keys => $value) {
                for ($i = 1; $i <= $count_rows; $i++) {
                    $data[$keys] = $value;
                }
            }
            foreach ($data as $keys => $values) {
                if ($increment == $count_rows) {
                    $columns[] = "{$keys} = '{$values}'";
                } else {
                    $columns[] = "{$keys} = '{$values}'";
                }
                $increment++;
            }
            $columns = implode(' , ', $columns);
            $wheres = $this->prepareWhere($params['wheres']);
            $query = "UPDATE `{$params['table']}`SET {$columns} {$wheres}";
            if (isset($params['debug']) and strtolower($params['debug']) === 'on') {
                var_dump($query);
            }

            return $query;
        } else {
            return false;
        }
    }
1026864
public static function upsert(array $values, array $updateColumns = null)
    {

        if (empty($values))
            return true;

        if (! is_array(reset($values))) {

            $values = [$values];

        } else {

            foreach ($values as $key => $value) {

                ksort($value);
                $values[$key] = $value;
            }
        }

        $model = self::getModel();

        $sql = static::compileUpsert(
            $model->getConnection()->getQueryGrammar(), $values, $updateColumns);

        $values = static::inLineArray($values);

        return $model->getConnection()->affectingStatement($sql, $values);
    }
1266831
public function getSalesDataForSubscribersWithOrderStatusesAndBrand($emails, $websiteId)
    {
        $orderStatuses = $this->config->getWebsiteConfig(
            Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
            $websiteId
        );
        $orderStatuses = explode(',', $orderStatuses);

        $orderCollection = $this->orderCollectionFactory->create()
            ->addFieldToSelect(['customer_email'])
            ->addExpressionFieldToSelect('total_spend', 'SUM({{grand_total}})', 'grand_total')
            ->addExpressionFieldToSelect('number_of_orders', 'COUNT({{*}})', '*')
            ->addExpressionFieldToSelect('average_order_value', 'AVG({{grand_total}})', 'grand_total')
            ->addFieldToFilter('customer_email', ['in' => $emails]);

        $columns = $this->buildCollectionColumns();
        $orderCollection->getSelect()
            ->columns($columns)
            ->group('customer_email');

        if (! empty($orderStatuses)) {
            $orderCollection->getSelect()->where('status in (?)', $orderStatuses);
        }

        $orderArray = [];
        foreach ($orderCollection as $item) {
            $orderArray[$item->getCustomerEmail()] = $item->toArray(
                [
                    'total_spend',
                    'number_of_orders',
                    'average_order_value',
                    'last_order_date',
                    'first_order_id',
                    'last_order_id',
                    'last_increment_id',
                    'product_id_for_first_brand',
                    'product_id_for_last_brand',
                    'week_day',
                    'month_day',
                    'product_id_for_most_sold_product'
                ]
            );
        }

        return $orderArray;
    }
309467
function update(req, res, next) {
  var options = req.connectionOptions;
  req.appformsResultPayload = req.appformsResultPayload || {};

  var params = {
    userEmail: req.user.email
  };

  options = _.extend(options, params);

  var form = req.body;

  if (_.isObject(req.appformsResultPayload.data) && !req.body._id) {
    form = req.appformsResultPayload.data;
  }

  logger.debug("Middleware: Update form: ", {options: options, form: form});

  forms.updateForm(options, form, formsResultHandlers(constants.resultTypes.forms, req, next));
}
1332270
public function update(array $fields = []) {
        $query = new UpdateQuery($this->getTable());
        $query->fields(!empty($fields)? $fields : $this->getFields());
        $query->whereConditionGroup($this->getWhereConditionGroup());
        return $this->connection->exec($query);
    }
835812
public function get_update_data_params(
		/** @noinspection PhpUnusedParameterInspection */
		$post, $update
	) {
		$params = [];
		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$params[ $k ] = $this->get_post_field( $k, $update || ! $v['required'] ? null : $v['default'], null, $v );
			$params[ $k ] = $this->sanitize_input( $params[ $k ], $v['type'] );
			if ( ! isset( $params[ $k ] ) && ! $update && $v['unset_if_null'] ) {
				unset( $params[ $k ] );
				continue;
			}
		}

		return $params;
	}
1223559
public function update(array $data)
    {
        // validate email address
        if (!empty($data['email_address']) &&
                !filter_var($data['email_address'], FILTER_VALIDATE_EMAIL)) {
            throw new Exception(
                'Invalid value for field email_address'
            );
        }
        $project_id = empty($data['project_id']) ? 0 : $data['project_id'];
        $permissions = empty($data['permissions']) ? null :
                                                (array) $data['permissions'];
        unset($data['project_id'], $data['permissions']);
        $save = false;
        if (!empty($data)) {
            $save = parent::update($data);
        }
        // add permission to project
        if ($project_id) {
            $permission = \TeamWorkPm\Factory::build('project/people');
            try {
                $add = $permission->add($project_id, $data['id']);
            } catch (Exception $e) {
                $add = $e->getMessage() == 'User is already on project';
            }
            $save = $save && $add;
            if ($add && $permissions) {
                $permissions['person_id']  = $data['id'];
                $permissions['project_id'] = $project_id;
                $save = $permission->update($permissions);
            }
        }
        return $save;
    }
1033793
public function create_user($username, $password, $email, $group = 1, Array $profile_fields = array())
	{
		$password = trim($password);
		$email = filter_var(trim($email), FILTER_VALIDATE_EMAIL);

		if (empty($username) or empty($password) or empty($email))
		{
			throw new \SimpleUserUpdateException('Username, password or email address is not given, or email address is invalid', 1);
		}

		$same_users = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
			->where('username', '=', $username)
			->or_where('email', '=', $email)
			->from(\Config::get('simpleauth.table_name'))
			->execute(\Config::get('simpleauth.db_connection'));

		if ($same_users->count() > 0)
		{
			if (in_array(strtolower($email), array_map('strtolower', $same_users->current())))
			{
				throw new \SimpleUserUpdateException('Email address already exists', 2);
			}
			else
			{
				throw new \SimpleUserUpdateException('Username already exists', 3);
			}
		}

		$user = array(
			'username'        => (string) $username,
			'password'        => $this->hash_password((string) $password),
			'email'           => $email,
			'group'           => (int) $group,
			'profile_fields'  => serialize($profile_fields),
			'last_login'      => 0,
			'login_hash'      => '',
			'created_at'      => \Date::forge()->get_timestamp()
		);
		$result = \DB::insert(\Config::get('simpleauth.table_name'))
			->set($user)
			->execute(\Config::get('simpleauth.db_connection'));

		return ($result[1] > 0) ? $result[0] : false;
	}
798471
public function applyResponseMap($updateTokens = false)
    {
        $responseMap = $this->getResponseMap();
        // Check the responseMap to discern where field values should go.
        if (count($responseMap)) {
            foreach ($responseMap as $alias => $value) {
                $oldValue = $this->contact->getFieldValue($alias);
                if ($oldValue !== $value) {
                    $this->contact->addUpdatedField($alias, $value, $oldValue);
                    if ($updateTokens) {
                        $this->tokenHelper->addContext([$alias => $value]);
                    }
                    $this->setLogs('Updating Contact: '.$alias.' = '.$value, 'fieldsUpdated');
                    $this->updatedFields = true;
                }
            }
        }

        return $this->updatedFields;
    }
856602
public function updateProfiles($userNames)
    {
        if (!is_array($userNames)) {
            return;
        }

        if (!is_object($this->profile)) {
            $this->profile = new Profile();
        }

        //Include required resources
        require_once(ABSPATH . 'wp-admin/includes/user.php');

        //Authentication
        $data = array(
            'username' => AD_BULK_IMPORT_USER,
            'password' => AD_BULK_IMPORT_PASSWORD
        );

        //Fetch user profiles
        $userDataArray = $this->curl->request('POST',
            rtrim(AD_INTEGRATION_URL, "/") . '/user/get/' . implode("/", $userNames) . "/", $data, 'json',
            array('Content-Type: application/json'));

        //Validate json response
        if ($this->response::isJsonError($userDataArray)) {
            return false;
        }

        //Decode
        $userDataArray = json_decode($userDataArray);

        //Update fetched users
        if (is_array($userDataArray) && !empty($userDataArray)) {
            foreach ($userDataArray as $user) {
                if (isset($user->samaccountname) && $userId = $this->userNameExists($user->samaccountname)) {
                    $this->profile->update($user, $userId, false);
                }
            }
        }

        //Remove this cron manually (WordPress builtin fails for some reason)
        wp_clear_scheduled_hook('ad_integration_bulk_update_profiles', array('userNames' => $userNames));
    }
1282917
final public function batchUpdate($scn, array $criteria, array $update)
    {
        return $this->getCollectionForModel($scn)->update($criteria, $update, ['multiple' => true]);
    }
507061
public function update($itemId, Google_Service_Chromewebstore_Item $postBody, $optParams = array())
  {
    $params = array('itemId' => $itemId, 'postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('update', array($params), "Google_Service_Chromewebstore_Item");
  }
8599
public function processSnapshotJob(array $query, $report_email = false, $postback_url = false, array $options = [ ]) {
        $data = [ 'query' => $query ];
        return $this->processJob('snaphot', $data, $report_email, $postback_url, [ ], $options);
    }
884465
public function actionProfile($update = false)
    {
        /** @var ProfileForm */
        $model = $this->module->createFormModel('ProfileForm');
        $model->setAttributes($model->getIdentity()->getIdentityAttributes());
        $loadedModel = $model->load($_POST);
        /** @var PasswordForm */
        $passwordForm = $this->module->createFormModel('PasswordForm');
        $loadedPassword = isset($_POST[$passwordForm->formName()]) && trim($_POST[$passwordForm->formName()]['newPassword']) !== '' && $passwordForm->load($_POST);
        if ($loadedModel) {
            if ($model->getIdentity() instanceof PictureIdentityInterface && !empty($model->pictureUploadRules)) {
                $model->picture = \yii\web\UploadedFile::getInstance($model, 'picture');
            }
            $passwordForm->password = $model->password;
        }

        if (Yii::$app->request->isAjax) {
            Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
            $models = [];
            if ($loadedModel) {
                $models[] = $model;
            }
            if ($loadedPassword) {
                $models[] = $passwordForm;
            }

            return \yii\widgets\ActiveForm::validateMultiple($models);
        }
        $flashes = ['success' => [], 'error' => []];
        /**
         * Only try to set new password if it has been specified in the form.
         * The current password could have been used to authorize other changes.
         */
        if ($loadedPassword) {
            if ($passwordForm->validate() && $passwordForm->resetPassword($model->getIdentity())) {
                $flashes['success'][] = Yii::t('usr', 'Changes have been saved successfully.');
            } else {
                $flashes['error'][] = Yii::t('usr', 'Failed to change password.');
            }
        }
        if ($loadedModel && empty($flashes['error'])) {
            if ($model->validate()) {
                $oldEmail = $model->getIdentity()->getEmail();
                if ($model->save($this->module->requireVerifiedEmail)) {
                    if ($this->module->requireVerifiedEmail && $oldEmail != $model->email) {
                        if ($this->sendEmail($model, 'verify')) {
                            $flashes['success'][] = Yii::t('usr', 'An email containing further instructions has been sent to provided email address.');
                        } else {
                            $flashes['error'][] = Yii::t('usr', 'Failed to send an email.').' '.Yii::t('usr', 'Try again or contact the site administrator.');
                        }
                    }
                    $flashes['success'][] = Yii::t('usr', 'Changes have been saved successfully.');
                    if (!empty($flashes['success'])) {
                        Yii::$app->session->setFlash('success', implode('<br/>', $flashes['success']));
                    }
                    if (!empty($flashes['error'])) {
                        Yii::$app->session->setFlash('error', implode('<br/>', $flashes['error']));
                    }

                    return $this->redirect(['profile']);
                } else {
                    $flashes['error'][] = Yii::t('usr', 'Failed to update profile.').' '.Yii::t('usr', 'Try again or contact the site administrator.');
                }
            }
        }
        if (!empty($flashes['success'])) {
            Yii::$app->session->setFlash('success', implode('<br/>', $flashes['success']));
        }
        if (!empty($flashes['error'])) {
            Yii::$app->session->setFlash('error', implode('<br/>', $flashes['error']));
        }
        if ($update) {
            return $this->render('updateProfile', ['model' => $model, 'passwordForm' => $passwordForm]);
        } else {
            return $this->render('viewProfile', ['model' => $model]);
        }
    }
582959
public function processUpdateJobFromFile($file, array $update = [ ], $report_email = false, $postback_url = false, array $options = [ ]) {
        return $this->processUpdateJob('file', $file, $update, $report_email, $postback_url, [ 'file' ], $options);
    }
769976
public function updateSubscriber($listId = '', $oldEmail = '', $email = '', $subscriber = array()) {
        $settings = CmService::$plugin->getSettings();

        try {
            $auth = array(
                'api_key' => (string)$settings->apiKey);
            $client = new \CS_REST_Subscribers(
                $listId,
                $auth);
            $result = $client->update($oldEmail, $subscriber);

            if($result->was_successful()) {
                $body = $result->response;
                return [
                    'success' => true,
                    'statusCode' => $result->http_status_code,
                    'body' => $body
                ];
            } else {
                return [
                    'success' => false,
                    'statusCode' => $result->http_status_code,
                    'reason' => $result->response->Message
                ];
            }
        } catch (\Exception $e) {
            return [
                'success' => false,
                'reason' => $e->getMessage()
            ];
        }
    }