By David Burroughs on Tuesday, 20 May 2014
Posted in General Issues
Replies 7
Likes 0
Views 439
Votes 0
I'm looking through the components source trying to figure out how to programmatically create a new group. I was ideally hoping you would point me to the correct location to do so. Essentially I am attempting to create a new group from the end of another javascript function. The js function will pass parameters (group name, etc.) into the create group function and the rest will be default(group type, etc).
Hi,

The data looks like this:

{"es-fields-22":"test","es-fields-24":"test","group_type":"1","es-fields-27":"","photo_albums":"1","es-fields-29":"1","es-fields-30":"1","es-fields-33":"{\"data\":\"\",\"position\":\"\"}"}

It varies depending on the field that the group have, and also depending on the field id of the field in the group.

While some field follows the key of "es-field-{id}", some uses a direct key such as "photo_albums".'

Unfortunately we can't actually list out all of the different keys and values for each individual fields but what you can do is go to the file /components/com_easysocial/controllers/groups.php and at around line 307 (may vary a little), search for the code $stepSession->delete(); and comment it out. Then try creating a group manually. This way the data will be intact in the database and you will be able to refer to the data format.
·
Wednesday, 04 June 2014 11:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi David,

I am sorry for the delay of this reply.

I am sorry but currently this is not possible to create a group by one single ajax request due to the complexity of the process flow. If you really want to hack your way through, then you can take a look at this controller JOOMLA/components/com_easysocial/controllers/groups.php and look for the 'store' function.

For your information, group creation required few steps and EasySocial actually stored the data for each steps in a temporary db table and these data will only process at the final step

Hope this help and have a nice day!
Sam
·
Tuesday, 20 May 2014 11:31
·
0 Likes
·
0 Votes
·
0 Comments
·
That answers my question for the most part. Natively I'm a Java developer so I'm still very new to web dev in general.

A follow up question would be if making a call to this "store" function from another class, how would I do so while still keeping the process flow intact?

Is there a schema for this temporary table that I can just dump data into and call the store function and the group will be created?
·
Tuesday, 03 June 2014 01:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

What you can refer to is the data in #__social_step_sessions. The value column contains the data needed to "create" a group.

This involves storing the data with the correct session id as well.

An overview of the table columns:

session_id: The session id retrieve using JFactory::getSession()->getId();

uid: The user id creating the groups

type: This should be "group" for your purpose

values: JSON string format of the data needed for the creation to work

step: Only used on creation to navigate between creation steps

step_access: Only used on creation to navigate between creation steps
·
Tuesday, 03 June 2014 13:36
·
0 Likes
·
0 Votes
·
0 Comments
·
Is there an example of the JSON format?
·
Wednesday, 04 June 2014 04:41
·
0 Likes
·
0 Votes
·
0 Comments
·
You are amazing. That is exactly what I was looking for. That is very helpful and I appreciate it greatly. I'll mark this as accepted and if I have any more questions it will likely be in another thread. Thanks for the support.
·
Wednesday, 04 June 2014 20:47
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Great and you've welcome.
·
Thursday, 05 June 2014 10:59
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post