Newsletter optins are updated

@param array $data
344446
public function updateNewsletter(array $data)
    {
        $user = $this->getAuthService()->getIdentity();
        $optinChange = false;
        $optin2Change = false;
        $optinPartnerChange = false;

        // I trigger an optin event before updating user if it has changed .
        if (isset($data['optin']) && $user->getOptin() != $data['optin']) {
            $optinChange = true;
            $this->getEventManager()->trigger(__FUNCTION__.'.pre', $this, array('user' => $user, 'data' => $data));
            $user->setOptin($data['optin']);
        }

        // I trigger an optin2 event before updating user if it has changed .
        if (isset($data['optin2']) && $user->getOptin2() != $data['optin2']) {
            $optin2Change = true;
            $this->getEventManager()->trigger(__FUNCTION__.'.pre', $this, array('user' => $user, 'data' => $data));
            $user->setOptin2($data['optin2']);
        }

        // I trigger an optinPartner event before updating user if it has changed
        if (isset($data['optinPartner']) && $user->getOptinPartner() != $data['optinPartner']) {
            $optinPartnerChange = true;
            $this->getEventManager()->trigger(__FUNCTION__.'Partner.pre', $this, array('user' => $user, 'data' => $data));
            $user->setOptinPartner($data['optinPartner']);
        }

        $form  = $this->getServiceManager()->get('playgrounduser_newsletter_form');
        $form->bind($user);
        $form->setData($data);

        /*if (!$form->isValid()) {
            return false;
        }*/

        $user = $this->getUserMapper()->update($user);
        if ($optinChange) {
            $this->getEventManager()->trigger(__FUNCTION__.'.post', $this, array('user' => $user, 'data' => $data));
        }

        if ($optin2Change) {
            $this->getEventManager()->trigger(__FUNCTION__.'.optin2.post', $this, array('user' => $user, 'data' => $data));
        }

        if ($optinPartnerChange) {
            $this->getEventManager()->trigger(__FUNCTION__.'Partner.post', $this, array('user' => $user, 'data' => $data));
        }

        return $user;
    }
1195037
public function populate($data = array())
    {
        if (isset($data['title']) && $data['title'] != null) {
            $this->title = $data['title'];
        }
        if (isset($data['address']) && $data['address'] != null) {
            $this->address = $data['address'];
        }
        if (isset($data['emailAddress']) && $data['emailAddress'] != null) {
            $this->emailAddress = $data['emailAddress'];
        }
        if (isset($data['emailName']) && $data['emailName'] != null) {
            $this->emailName = $data['emailName'];
        }
        if (isset($data['phoneNumber']) && $data['phoneNumber'] != null) {
            $this->phoneNumber = $data['phoneNumber'];
        }
        if (isset($data['facebookPage']) && $data['facebookPage'] != null) {
            $this->facebookPage = $data['facebookPage'];
        }
        if (isset($data['twitterAccount']) && $data['twitterAccount'] != null) {
            $this->twitterAccount = $data['twitterAccount'];
        }
        if (isset($data['googleAnalytics']) && $data['googleAnalytics'] != null) {
            $this->googleAnalytics = $data['googleAnalytics'];
        }
        if (isset($data['mainImage']) && $data['mainImage'] != null) {
            $this->mainImage = $data['mainImage'];
        }
    }
790117
public function update(array $data)
    {
        $perm = $this->findOrFail($data['id']);

        $perm->name = $data['name'];
        $perm->permissions = $data['permissions'];
        $perm->save();

        $this->event->fire('permissions.update',array($perm));

        return true;
    }
97870
public function updateNewsMaterial(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MATERIAL_DELETE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && !$result['errcode'];
    }
904469
public function setStartUpdate(array $data)
    {
        $this->setStart("UPDATE ".$this->model->getDbTable()." SET ".$this->getColumnsForUpdate($data));
    }
872421
private function internalDataListUpdateAllValuesIfNeeded(&$data)
    {
        foreach ($data as $index => $value) {
            $this->internalDataListUpdateValueIfNeeded($data, $index);
        }
    }
1069597
public function update_config(&$data) {
        global $DB;

        if (!empty($data->criteria_activity) && is_array($data->criteria_activity)) {

            $this->course = $data->id;

            // Data comes from advcheckbox, so contains keys for all activities.
            // A value of 0 is 'not checked' whereas 1 is 'checked'.
            foreach ($data->criteria_activity as $activity => $val) {
                // Only update those which are checked.
                if (!empty($val)) {
                    $module = $DB->get_record('course_modules', array('id' => $activity));
                    $this->module = self::get_mod_name($module->module);
                    $this->moduleinstance = $activity;
                    $this->id = null;
                    $this->insert();
                }
            }
        }
    }
342231
public function update(array $data)
    {
        if ( $this->validator->with($data)->validForUpdate() )
        {
            $data['permissions'] = explode(',', $data['permissions']);
            $this->permission->update($data);
            return true;
        }
        else
        {
            return false;
        }
    }
299799
protected function _update(array $data = array(), array $criteria = array())
    {
        if (!is_null($this->_table)) {
            $this->_affectedRows = $this->_db->update($this->_table, $data, $criteria);
            return $this->_affectedRows;
        }
    }
971496
protected function _update(array $data)
    {
        $data = $this->_setData($data);
        $pmk = $this->getPrimaryKey();
        unset($data[$pmk]);
        $sql = Sql::createSql($this->getAdapter())->update($this->getTableName());
        $event = new Save([
            'action' => Save::UPDATE,
            'data' => $data,
            'abort' => false
        ]);
        $this->getEventManager()->trigger(Save::BEFORE_SAVE, $this, $event);
        if ($event->abort) {
            return false;
        }
        $sql->set($event->data)
            ->where(["{$pmk} = :id" => [':id' => $this->$pmk]])
            ->execute();
        $this->getEventManager()->trigger(Save::AFTER_SAVE, $this, $event);
        return true;
    }
963754
public function afterUpdate(array &$args) {
        // Check if an email address was changed. If so, send a validation email
        $data = $args[2];
        if (array_key_exists('email', $data) && $this->_validateEmail) {
            $this->_onEmailChange($data['email'], 'update');
        }
    }
102406
public function update(array $data, $VoucherType = null)
  {
    if(empty($VoucherType))
    {
      $VoucherType = $this->byId($data['id']);
    }

    foreach ($data as $key => $value)
    {
      $VoucherType->$key = $value;
    }

    return $VoucherType->save();
  }
278306
public function populate($data = array())
    {
        if (isset($data['id']) && $data['id'] != null) {
            $this->id    = $data['id'];
        }

        if (isset($data['password']) && $data['password'] != null) {
            $this->password    = $data['password'];
        }
        if (isset($data['avatar']) && $data['avatar'] != null) {
            $this->avatar    = $data['avatar'];
        }
        if (isset($data['state'])) {
            $this->state    = $data['state'];
        }
        if (isset($data['postalCode'])) {
            $this->postalCode    = $data['postalCode'];
        }

        if (isset($data['dob']) && $data['dob'] != null) {
            $this->dob = DateTime::createFromFormat('Y-m-d', $data['dob']);
        }

        if (isset($data['optin'])) {
            $this->optin    = $data['optin'];
        }

        if (isset($data['optin2'])) {
            $this->optin2    = $data['optin2'];
        }

        if (isset($data['optinPartner'])) {
            $this->optinPartner    = $data['optinPartner'];
        }
        if (isset($data['username']) && $data['username'] != null) {
            $this->username    = $data['username'];
        }
        if (isset($data['email']) && $data['email'] != null) {
            $this->email    = $data['email'];
        }
        if (isset($data['displayName']) && $data['displayName'] != null) {
            $this->displayName    = $data['displayName'];
        }
        if (isset($data['firstname']) && $data['firstname'] != null) {
            $this->firstname    = $data['firstname'];
        }
        if (isset($data['lastname']) && $data['lastname'] != null) {
            $this->lastname    = $data['lastname'];
        }
        if (isset($data['title']) && $data['title'] != null) {
            $this->title    = $data['title'];
        }
        if (isset($data['address']) && $data['address'] != null) {
            $this->address    = $data['address'];
        }
        if (isset($data['address2'])) {
            $this->address2    = $data['address2'];
        }
        if (isset($data['city']) && $data['city'] != null) {
            $this->city    = $data['city'];
        }
        if (isset($data['country']) && $data['country'] != null) {
            $this->country    = $data['country'];
        }
        if (isset($data['telephone']) && $data['telephone'] != null) {
            $this->telephone    = $data['telephone'];
        }
        if (isset($data['mobile']) && $data['mobile'] != null) {
            $this->mobile    = $data['mobile'];
        }
        if (isset($data['registrationSource']) && $data['registrationSource'] != null) {
            $this->registrationSource    = $data['registrationSource'];
        }
    }
1004090
public function insertUpdate(array $data)
    {
        $affected = $this->update($data);
        return $affected ?: $this->insert($data);
    }
1081007
public function populate($data = array())
    {
        parent::populate($data);

        if (isset($data['postDisplayMode']) && $data['postDisplayMode'] !== null) {
            $this->postDisplayMode = $data['postDisplayMode'];
        }

        if (isset($data['voteAnonymous']) && $data['voteAnonymous'] !== null) {
            $this->voteAnonymous = $data['voteAnonymous'];
        }
    }
675048
public function updateIf($data)
    {
        $updated = false;
        foreach ($data as $key => $val) {
            if ($val) {
                $this->{$key} = $val;
                $updated = true;
            }
        }

        if ($updated) {
            $this->save();
        }

        return $this;
    }
354139
public function update(array $data)
    {
        try
        {
            if ($this->validator->with($data)->validForUpdate())
            {
                $this->groups->update($data);
                return true;
            }
        }
        catch (GroupExistsException $e)
        {
            $this->validator->add('GroupExistsException', $e->getMessage());
        }
        catch (NameRequiredException $e)
        {
            $this->validator->add('NameRequiredException', $e->getMessage());
        }

        return false;
    }