... ...

API > Groups

Basic JavaScript object

Membership.api.groups

getActivity

Gets list of activity for the certain group.

Parameters

  • groupId
    ID of a group for which is needed to get activity
  • limit
    Maximum number of activities which has to be returned. By default 5, minumum value 1, maximum value 20.
  • offsetId
    Activity ID regarding to which activities needed to be received in descending order.

Result

After success returns object with properties success and html.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Activity/views/partials/activities.twig with specified in request user.

Example

Membership.api.users.getActivity({
    groupId: 1,
    limit: 10,
    offsetId: null
});

postActivity

Publishes post on a group page.

Parameters

  • groupId
    ID of a group for which is needed to get activity.
  • data
    Object with properties for publication

    Available properties:

    • message
      Message text
    • link
      Link ID to display in the post, can be received after the method call parseUrlAttachment
    • images
      Image ID array which has to be attached to the post, can be received after the call uploadImage
  • isCommunityPost
    Publiches post on behalf of a group.

Result

After success returns object with properties success and html.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Activity/views/partials/activities.twig with specified in request user.

Example

Membership.api.groups.postActivity({
    groupId: 1,
    data: {
        message: 'Hello',
        images: [100, 101, 102],
        link: 'fef0e980f7d3cf3bbda271095c5041ea32c98343'
    },
    isCommunityPost: isCommunityPost
});

removeActivity

Remopves post on a group page.

Parameters

  • activityId
    ID of a post which has to be deleted.

Result

After success returns object which contains request status in success property.

  • success

Example

Membership.api.groups.removeActivity({
    activityId: 1
});

Changes group logo.

Parameters

  • groupId
    ID of a group for which is needed to change logo.
  • attachmentId
    ID of uploaded image. Can be received in method Membership.base.uploadImage
  • cropData

    Object with properties to crop an image.

    x: x-axis offset of cropped area

    y: y-axis offset of cropped area

    width: width of image cropped area

    height: height of image cropped area

Result

Returns object with properties success and image:

  • success
    Request status true in a case of success or false in a case of error.
  • images
    Image array of specified group with types: cover, logo and specified in the plugin settings sizes.

Example

Membership.api.groups.changeLogo({
    groupId: 1,
    attachmentId: 100,
    cropData: {
        x: 0,
        y: 118,
        width: 1000,
        height: 375,
    }
})

Removes group logo.

Parameters

  • groupId
    ID of a group for which logo has to be deleted.

Result

Returns object which contains property with request result: success

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.groups.removeLogo({
    groupId: 1
})

changeCover

Changes group cover.

Parameters

  • groupId
    ID of a group for which cover has to be changed.
  • attachmentId
    ID of uploaded image. Can be received in method Membership.base.uploadImage
  • cropData

    Object with properties to crop an image.

    x: x-axis offset of cropped area

    y: y-axis offset of cropped area

    width: width of image cropped area

    height: height of image cropped area

Result

Returns object with properties success and image:

  • success
    Request status true in a case of success or false in a case of error.
  • images
    Image array of specified group with types: cover, logo and specified in the plugin settings sizes.

Example

Membership.api.groups.changeCover({
    groupId: 1,
    attachmentId: 100,
    cropData: {
        x: 0,
        y: 118,
        width: 1000,
        height: 375,
    }
})

removeCover

Removes group cover.

Parameters

  • groupId
    ID of a group for which cover has to be removed.

Result

Returns object which contains property with request result: success

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.groups.removeCover({
    groupId: 1
})

join

Creates request to join a group if the group is “Closed” type, or joins the group if the group is “Open” type. Also confirms group invitation.

Parameters

  • groupId
    Group ID.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig
  • message
    Error message in a case of unseccessful request.
  • status
    Status code of HTTP in a case of unseccessful request.

Example

Membership.api.groups.join({
    groupId: 1
});

leave

Cancels membership request if a group is “Closed” type or removes current user from the group if the group is “Open” type. Also cancel group invitation.

Parameters

  • groupId
    Group ID.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig
  • message
    Error message in a case of unseccessful request.
  • status
    Status code of HTTP in a case of unseccessful request.

Example

Membership.api.groups.leave({
    groupId: 1
});

delete

Deletes group. Available only for a user with a role of group administrator.

Parameters

  • groupId
    Group ID.

Result

Returns object which contains such properties: success and redirect in a case of success or success and message in a case of error:

  • success
    Request status true in a case of success or false in a case of error.
  • redirect
    A link to redirect user after deleting.
  • message
    Error message in a case of unseccessful request.

Example

Membership.api.groups.delete({
    groupId: 1
});

follow

Subscrtibers user to a certain group.

Parameters

  • groupId
    ID of a group to subscribe.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig
  • message
    Error message in a case of unseccessful request.
  • status
    Status code of HTTP.

Example

Membership.api.groups.follow({
    groupId: 1
});

unfollow

Unsubscribes user from a certain group.

Parameters

  • groupId
    ID of a group to unsubscribe.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, message.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig

Example

Membership.api.groups.unfollow({
    groupId: 1
});

getUsers

Returns list of users related to a group.

Parameters

  • groupId
    ID of a group for which is needed to get a list.
  • status
    User status

    Available status for everyone

    • approved User is approved.

    Available statuses only for group administrator

    • unapproved User is waiting for approval
    • invited Invited user
    • blocked Blocked user
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 20.
  • offset
    Offset needed for selecting a certain subset of users.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/users-list.twig
  • status
    Status code of HTTP.

Example

Membership.api.groups.getUsers({
    groupId: 1,
    status: 'approved',
    limit: '10',
    offsetId: null,
    search: 'John'
});

removeUser

Removes user/users from a group and blocks them due to mentioned parameter.

Parameters

  • groupId
    Group ID.
  • userId
    User ID.
  • block
    Add user to a blacklist.

Result

Returns object which contains such properties: success in a case of success and status in a case of error.

  • success
    Request status true in a case of success or false in a case of error.
  • status
    Status code of HTTP.

Example

Membership.api.groups.getUsers({
    groupId: 1,
    userId: 2,
    block: false
});

unblockUser

Unblocks user in a group.

Parameters

  • groupId
    Group ID.
  • userId
    User ID.

Result

Returns object which contains such properties: success in a case of success and status in a case of error.

  • success
    Request status true in a case of success or false in a case of error.
  • status
    Status code of HTTP.

Example

Membership.api.groups.unblockUser({
    groupId: 1,
    userId: 2
});

approveUser

Confirms membership request from a user.

Parameters

  • groupId
    Group ID.
  • userId
    User ID.

Result

Returns object which contains such properties: success in a case of success and status in a case of error.

  • success
    Request status true in a case of success or false in a case of error.
  • status
    Status code of HTTP.

Example

Membership.api.groups.approveUser({
    groupId: 1,
    userId: 2
});

getUsersToInvite

Returns a list of users who are not a group members and are not invited yet, if the groupId parameter is specified.

Parameters

  • groupId
    ID of a group for which is neede to get a list.
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    User ID regarding to which a list will be displayed in descending order.
  • search
    Field with user name according to which is needed to filter result.
  • template
    A template with the help of which a list be rendered.

    Acceptable values

    • invite-modal will be rendered membership-by-supsystic/src/Membership/Groups/views/partials/invite-modal-users.twig
    • search-dropdown will be rendered membership-by-supsystic/src/Membership/Base/partials/search-dropdown-user.twig

Result

Returns object which contains such properties: success in a case of success and html in a case of error success, status.

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/invite-modal-users.twig or membership-by-supsystic/src/Membership/Base/partials/search-dropdown-user.twig
  • status
    Status code of HTTP.

Example

Membership.api.groups.getUsersToInvite({
    groupId: 1,
    limit: '10',
    offsetId: null,
    search: 'John'
});

invite

Sends an invitation to a user to join a group.

Parameters

  • groupId
    Group ID.
  • userId
    User ID.
  • role
    User role

    Acceptable values
    user

    Acceptable values only fro a group administrator
    administrator

Result

Returns object which contains such properties: success in a case of success, and success and status in a case of error.

  • success
    Request status true in a case of success or false in a case of error.
  • status
    Status code of HTTP.

Example

Membership.api.groups.invite({
    groupId: 1,
    userId: 1,
    role: 'user'
});

cancelInvite

Removes or calcels invitation to join a group.

Parameters

  • groupId
    Group ID.
  • userId
    User ID.

Result

Returns object which contains such properties: success in a case of success and html in a case of error success и status.

  • success
    Request status true in a case of success or false in a case of error.
  • status
    Status code of HTTP.

Example

Membership.api.groups.cancelInvite({
    groupId: 1,
    userId: 1,
    role: 'user'
});

updatePrivacy

Updates privacy settings of a group.

Parameters

Group ID.

  • privacies
    Object of settings which contains pairs setting name – value.

    Acceptable names of privacy settings.

    • type Type of a group.
      • open Open group, any user can join
      • closed Closed group, user sends membership request and group administrator has to approve it.
      • private Private group, isn’t shown anywhere and user can join it only by invitation.
    • read-activity Reading content
      • all All users can read post in a group
      • members-only Only users who joined a group can see posts
    • post-activity Publishing posts
      • all All users can publish posts
      • members-only Only users who joined a group can publish posts
      • administrators Only administrators can publish posts
    • post-comments Leaves comments to posts
      • all All users can leave comments
      • members-only Only users who joined a group can leave comments
      • administrators Only administrators can leave comments
    • invitations Invite other users to a group
      • all All users can invite other users
      • administrators Only administrators can invite other users

Result

Returns object with properties success and message:

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about successful change of settings or error message.

Example

Membership.api.groups.updatePrivacy({
    groupId: 1,
    privacies: {
       'type': 'open',
       'read-activity': 'all',
       'post-activity': 'members-only',
       'post-comments': 'administrators',
       'invitations': 'all'
    }
});

updateData

Updates group data.

Parameters

  • groupId
    Group ID.
  • data
    Object which contains pairs property name – value
    Acceptable properties.

    • name Group name.
    • description Group description.

Result

Returns object with properties success and message:

  • success
    Request status true in a case of success or false in a case of error.
  • message
    Message about successful change of data or error message.

Example

Membership.api.groups.updateData({
    groupId: 1,
    data: {
       'name': 'My Group',
       'description': 'My Group Description'
    }
});

get

Returns list of groups.

Parameters

  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    Group ID regarding to which a list will be displayed in descending order.
  • search
    Field with group name according to which is needed to filter result.

Result

Returns object with properties success and html

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig

Example

Membership.api.groups.get({
    limi: 10,
    offsetId: null,
    search: null
});

getUserGroups

Returns a list of groups of a current user.

Parameters

  • type Type of a group..
    joined A group which user has joined.
    managed A group where user is administrator.
    invited A group where user was invited.
  • limit
    Maximum number of users which has to be returned. By default 10, minumum value 1, maximum value 50.
  • offsetId
    Group ID regarding to which a list will be displayed in descending order.
  • search
    Field with group name according to which is needed to filter result.

Result

Returns object with properties success and html:

  • success
    Request status true in a case of success or false in a case of error.
  • html
    Template render membership-by-supsystic/src/Membership/Groups/views/partials/groups-list.twig

Example

Membership.api.groups.updateData({
    groupId: 1,
    data: {
       'name': 'My Group',
       'description': 'My Group Description'
    }
});

createGroup

Creates new group.

Parameters

  • name
    Group name.
  • description
    Group description
  • type
    Group type.
    Acceptable types

    • open Open group, any user can join
    • closed Closed group, user sends membership request and group administrator has to approve it.
    • private Private group, isn’t shown anywhere and user can join it only by invitation.
  • invitedUsers
    Array with user IDs that you want to send invitations to join a group after creation of a group.

Result

Returns object with properties success, redirect and message.

  • success
    Request status true in a case of success or false in a case of error.
  • redirect
    Link to a created group.
  • message
    Message about successful group creation or error message.

Example

Membership.api.groups.createGroup({
    name: 'My Group',
    description: 'My Group Description',
    type: 'open',
    invitedUsers: [100, 101, 102]
});

block

Blocks group.

Parameters

  • groupId
    Group ID.

Result

Returns object with success property.

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.groups.block({
    groupId: groupId
});

unblock

Unblocks group.

Parameters

  • groupId
    Group ID.

Result

Returns object with success property.

  • success
    Request status true in a case of success or false in a case of error.

Example

Membership.api.groups.unblock({
    groupId: groupId
});

Categories
Latest Articles