/*
update the group assignment for the user. return true if at least one group was changed
@return boolean
324070
public static function UpdateAutoAssignToUser($oUser)
    {
        $dOrderValue = $oUser->GetTotalOrderValue();
        $bResult = TdbDataExtranetGroup::UpdateAutoAssignToUserQuick($oUser->id, $dOrderValue);

        return $bResult;
    }
334726
protected function assignGroupsToAssignment()
    {
        $assignment = fp_env('ACACHA_FORGE_ASSIGNMENT');
        foreach ( $this->groups as $group) {
            $uri = str_replace('{assignment}', $assignment, config('forge-publish.assign_group_to_assignment_uri'));
            $uri = str_replace('{group}', $group, $uri);
            $url = config('forge-publish.url') . $uri;
            try {
                $response = $this->http->post($url, [
                    'headers' => [
                        'X-Requested-With' => 'XMLHttpRequest',
                        'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
                    ]
                ]);
            } catch (\Exception $e) {
                if ($e->getResponse()->getStatusCode() == 422) {
                    $this->error('The group is already assigned');
                    return;
                }
                $this->error('And error occurs connecting to the api url: ' . $url);
                $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
                return [];
            }
        }
    }
437573
public function update($ids)
    {
        if (empty($ids)) {
            return false;
        } elseif (empty($this->_ids)) {
            $this->_ids = $ids;
            $change = true;
        } else {
            $change = false;
            foreach ($ids as $k => $v) {
                if (!isset($this->_ids[$k]) || ($this->_ids[$k] != $v)) {
                    $this->_ids[$k] = $v;
                    $change = true;
                }
            }
        }

        if ($change) {
            $this->_sorted = false;
        }

        return $change;
    }
557050
public function addGroup($group) {
    if (!$group->inArray((array) $this->groups)) {
      $this->groups[] = $group;
      return $this->groups;
    }
    return true;
  }
918671
public function change()
    {
        $table = $this->table('groups');
        $table->changeColumn('name', 'string', [
            'default' => null,
            'limit' => 255,
            'null' => false,
        ]);
        $table->addIndex([
            'name',
        ], [
            'name' => 'UNIQUE_NAME',
            'unique' => true,
        ]);
        $table->update();
    }
1066960
public function updateGroup($groupid,$name){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $data = array(
                'group'=>array('id'=>$groupid,'name'=>$name)
        );
        $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_UPDATE_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
559197
def _group_changes(cur, wanted, remove=False):
    '''
    
    '''
    old = set(cur)
    new = set(wanted)
    if (remove and old != new) or (not remove and not new.issubset(old)):
        return True
    return False
1026042
public function refreshGroupSettings()
    {
        $group = $this->currentUser->getGroup();
        if ($group instanceof Group) {
            $group->applyGroupToModel($this, false);
        }
    }
650835
public function update($group)
    {
        if (is_string($group)) {
            $group = $this->groupFactory->createForPlayer($group);
        } else {
            if (is_array($group)) {
                $group = $this->groupFactory->createForPlayers($group);
            }
        }

        $ml = $this->guiHandler->getManialink($group, $this);
        if ($ml) {
            $this->actionFactory->destroyNotPermanentActions($ml);
            if ($ml instanceof Window) {
                $ml->busyCounter += 1;

                if ($ml->isBusy && $ml->busyCounter > 1) {
                    $ml->setBusy(false);
                }
            }
            $this->updateContent($ml);
            $this->guiHandler->addToDisplay($ml, $this);
        }
    }
636474
public function change_group($group)
    {

        if (empty($group) || !is_int($group)) return false;

        if (chgrp($this->path . $this->filename, $group)) {
            return $this->open($this->path . $this->filename);
        }

        return false;
    }
336422
public function set_usergroup($user_id, $group_id)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $payload  = ['usergroup_id' => $group_id];
        $response = $this->exec_curl('/api/s/' . $this->site . '/upd/user/' . trim($user_id), $payload);

        return $this->process_response_boolean($response);
    }
1226392
public function delete()
    {
        if ($this->id == 0 || $this->id == ADMIN_ID) return FALSE;
		$conn = self::getDbConnection();
		$str = 'DELETE [LOGIN='.$this->login.'][ID='.$this->id.']';
        $conn->executeQuery('DELETE FROM users_groups_membership WHERE user_id='.$this->id);
        $conn->executeQuery('DELETE FROM users_auth WHERE user_id='.$this->id);
        parent::delete();
			
	    Event::trigger(EVENT_CORE_USER_PROP,['message' => $str]);
    }
310626
public function updateUserGroup(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MEMBER_GROUP_UPDATE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
1199032
protected function isUserAssignedToGroup($groups)
    {
        $isValid = false;

        $user = $this->getUser();
        foreach ($groups as $group) {
            if ($user->inGroup($group->getId())) {
                $isValid = true;
                break;
            }
        }

        return $isValid;
    }
588783
public function updateGroupUsers($uids, $gid) {
		if(is_array($uids)) {
			$uids = implode(',', $uids);
		}

		$query = WechatUser::find()->where("id in ($uids) and groupid <> $gid");
		$users = $query->all();
		$openids = ArrayHelper::getColumn($users, 'openid');

		if(!$openids) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/batchupdate', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid_list' => $openids,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result) {
			foreach($users as $user) {
				if($user->group->updateCounters(['count' => -1])) {
					$user->groupid = $gid;
					if($user->save()) {
						$user->refresh();
						$user->group->updateCounters(['count' => 1]);
					}
				}
			}
		}

		return $result;
	}
1253857
public function updateGroup(GroupUpdateStruct $group)
    {
        $q = $this->dbHandler->createUpdateQuery();
        $q->update(
            $this->dbHandler->quoteColumn('ezcontentclassgroup')
        )->set(
            $this->dbHandler->quoteColumn('modified'),
            $q->bindValue($group->modified, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('modifier_id'),
            $q->bindValue($group->modifierId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('name'),
            $q->bindValue($group->identifier)
        )->where(
            $q->expr->eq(
                $this->dbHandler->quoteColumn('id'),
                $q->bindValue($group->id, null, \PDO::PARAM_INT)
            )
        );

        $q->prepare()->execute();
    }
287697
public function update() {
        $this->isNewRecord = false;
        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }
        $this->invoke(self::BEFORE_UPDATE, [$this]);
        if (!$this->validate()) {
            return false;
        }
        $query = $this->getPrimaryKeyQuery();
        if (empty($query)) {
            $this->setError('pk', 'ERROR PK!');
            return false;
        }
        $data = $this->_getRealFields();
        if (empty($data)) {
            return true;
        }
        $row = $query
            ->update($data);
        if (!empty($row)) {
            $this->setOldAttribute();
        } else {
            $this->setError('data', 'Data is not change!');
        }
        $this->invoke(self::AFTER_UPDATE, [$this]);
        return $row;
    }