DEPRECATED. use membership.create()
505909
@Deprecated
    public Membership addUserToProject(int projectId, int userId, Collection<Role> roles) throws RedmineException {
        return new Membership(transport)
                .setProject(new Project(transport).setId(projectId))
                .setUserId(userId)
                .addRoles(roles)
                .create();
    }
1117868
static MembersView cloneAdding(MembersView source, Collection<MemberInfo> newMembers) {
        List<MemberInfo> list = new ArrayList<>(source.size() + newMembers.size());
        list.addAll(source.getMembers());
        int newVersion = max(source.version, source.size());
        for (MemberInfo newMember : newMembers) {
            MemberInfo m = new MemberInfo(newMember.getAddress(), newMember.getUuid(), newMember.getAttributes(),
                    newMember.isLiteMember(), newMember.getVersion(), ++newVersion, newMember.getAddressMap());
            list.add(m);
        }

        return new MembersView(newVersion, unmodifiableList(list));
    }
206327
def create_session(self, username, prekeybundle, autotrust=False):
        
        logger.debug("create_session(username=%s, prekeybunder=[omitted], autotrust=%s)" % (username, autotrust))
        session_builder = SessionBuilder(self._store, self._store, self._store, self._store, username, 1)
        try:
            session_builder.processPreKeyBundle(prekeybundle)
        except UntrustedIdentityException as ex:
            if autotrust:
                self.trust_identity(ex.getName(), ex.getIdentityKey())
            else:
                raise exceptions.UntrustedIdentityException(ex.getName(), ex.getIdentityKey())
265326
def create
      if @membershipable.present?
        @membership = @membershipable.memberships.new(membership_params)
      else
        @membership = Membership.new(membership_params)
      end

      @membership.save
      respond_with(@membership, location: location)
    end
786204
def add_membership(self, member, role=github.GithubObject.NotSet):
        
        assert isinstance(member, github.NamedUser.NamedUser), member
        assert role is github.GithubObject.NotSet or isinstance(
            role, (str, unicode)), role
        if role is not github.GithubObject.NotSet:
            assert role in ['member', 'maintainer']
            put_parameters = {
                "role": role,
            }
        else:
            put_parameters = {
                "role": "member",
            }
        headers, data = self._requester.requestJsonAndCheck(
            "PUT",
            self.url + "/memberships/" + member._identity,
            input=put_parameters
        )
1136335
def _create_user(ctx):
    """"""

    username, passhash = _get_credentials(ctx.obj['username'],
                                          ctx.obj['password'],
                                          ctx.obj['db'])

    if ctx.obj['db'].objectmodels['user'].count({'name': username}) > 0:
        raise KeyError()

    new_user = ctx.obj['db'].objectmodels['user']({
        'uuid': str(uuid4()),
        'created': std_now()
    })

    new_user.name = username
    new_user.passhash = passhash

    return new_user
1026034
def create(cls, user_id, github_id=None, name=None, **kwargs):
        """"""
        with db.session.begin_nested():
            obj = cls(user_id=user_id, github_id=github_id, name=name,
                      **kwargs)
            db.session.add(obj)
        return obj
787681
def create_membership(organization_id, params)
      http.post(membership_endpoint(organization_id), body: params) do |response|
        response.parsed_body
      end
    end
1029069
function (member, memberValue, visibility) {
        var newType = typeof memberValue,
            baseMemberValue,
            baseType,
            prototype = this._Constructor.prototype;
        _gpfAssert(!prototype.hasOwnProperty(member), "Existing own member can't be overridden");
        baseMemberValue = this._Super.prototype[member];
        baseType = typeof baseMemberValue;
        if ("undefined" !== baseType) {
            if (null !== baseMemberValue && newType !== baseType) {
                gpf.Error.classMemberOverloadWithTypeChange();
            }
            if ("function" === newType && _gpfUsesSuper(memberValue)) {
                memberValue = _gpfGenSuperMember(baseMemberValue, memberValue);
            }
        }
        _gpfIgnore(visibility); // TODO Handle constructor visibility
        prototype[member] = memberValue;
    }
229146
def new(cls,
            username,
            password=None,
            email=None,
            first_name="",
            last_name="",
            login_method=None,
            role="MEMBER"
            ):
        
        data = {
            "first_name": first_name,
            "last_name": last_name,
            "email": email
        }

        if not password:
            password = utils.generate_random_string()

        username = username.strip().lower()
        if "@" in username and not email:
            if not utils.is_email_valid(username):
                exceptions.AuthError(_("Invalid username"))
            data["email"] = username
        elif email:
            if not utils.is_email_valid(email):
                exceptions.AuthError(_("Invalid username"))

        if not utils.is_username_valid(username):
            exceptions.AuthError(_("Invalid username"))
        if not utils.is_password_valid(password):
            raise exceptions.AuthError(_("Password is invalid"))

        if cls.get_by_username(username):
            raise exceptions.AuthError(_("Username exists already"))
        _email = data.get("email")
        if _email:
            if cls.get_by_email(_email):
                raise exceptions.AuthError(_("Email address exists already"))

        role = AuthUserRole.get_by_name(role or "MEMBER")
        if not role:
            raise exceptions.AuthError(_("Invalid user role"))

        data.update({
            "username": username,
            "password_hash": cls.encrypt_password(password),
            "email_verified": False,
            "login_method": login_method,
            "role": role,
            "status": cls.STATUS_ACTIVE
        })
        user = cls.create(**data)
        user.reset_secret_key()
        return user
718758
private MembershipType saveMembershipType(Session session, MembershipTypeImpl mType, boolean broadcast)
      throws Exception
   {
      Node mtNode = getOrCreateMembershipTypeNode(session, mType);

      boolean isNew = mtNode.isNew();

      if (broadcast)
      {
         preSave(mType, isNew);
      }

      String oldType =
         mtNode.getName().equals(JCROrganizationServiceImpl.JOS_MEMBERSHIP_TYPE_ANY) ? ANY_MEMBERSHIP_TYPE : mtNode
            .getName();
      String newType = mType.getName();

      if (!oldType.equals(newType))
      {
         String oldPath = mtNode.getPath();
         String newPath = utils.getMembershipTypeNodePath(newType);

         session.move(oldPath, newPath);

         moveMembershipsInCache(oldType, newType);
         removeFromCache(oldType);
      }

      writeMembershipType(mType, mtNode);
      session.save();

      putInCache(mType);

      if (broadcast)
      {
         postSave(mType, isNew);
      }

      return mType;
   }
722721
def do_membership(args):
    
    config,name,label,coord = args

    filenames = make_filenames(config,label)
    srcfile = filenames['srcfile']
    memfile = filenames['memfile']

    logger.info("Writing %s..."%memfile)
    from ugali.analysis.loglike import write_membership
    write_membership(memfile,config,srcfile,section='source')
634380
function(ns, members) {
			var no;
			if (gui.Type.isString(ns)) {
				no = gui.Object.lookup(ns);
				no = new gui.Namespace(ns);
				no = gui.Object.assert(ns, no);
			} else {
				throw new TypeError("Expected a namespace string");
			}
			return gui.Object.extend(no, members || {});
		}
764645
function create(body, cb) {
  var validates = Schema(body);

  if(!validates) {
    return cb(new exceptions.BadRequest());
  }

  body.expires_at = stampify(conf.session_maxage);

  var q = qb.insert(body);
  db.getClient(function(err, client, done) {
    client.query(q[0], q[1], function(err, r) {
      if(err) {
        if(err.code == 23505) {
          err = new exceptions.AlreadyExists();
        }
        cb(err);
        done(err);
      } else {
        cb(null, r.rows[0]);
        done();
      }
    });
  });
}
189107
function createUser({ username, group="public" }, done) {
  return getGroup(group, function(getGroupErr, theGroup) {
    if (getGroupErr) {
      return done(getGroupErr);
    }

    if (!theGroup) {
      return done(new Error(`group '${group}' not found`));
    }

    theGroup.members.add({ username });
    return theGroup.save(done);
  });
}
770644
function addMember(path, memberPath, setId, msg) {
            // FIXME: This will have to break due to switched arguments
            var node = _getNode(path),
                memberNode = _getNode(memberPath);

            if (node && memberNode) {
                state.core.addMember(node, setId, memberNode);
                saveRoot(typeof msg === 'string' ? msg : 'addMember(' + path + ',' + memberPath + ',' + setId + ')');
            }
        }
1232393
@Deprecated
    public void deleteProjectMembership(Membership membership) throws RedmineException {
        transport.deleteObject(Membership.class, membership.getId().toString());
    }