Importing existing user data..

12 years 6 months ago #180497 by krileon
Replied by krileon on topic Re: Importing existing user data..

It still *appears* to be doing direct database stuff - does the technique outlined there also manage ACL assignment/memberships?

It's a database object, which will also execute other APIs.. like a chain reaction basically.. yes, it handles the ACL as well.

Probably using "usertype", I guess.

That and gid (gids if J1.7).

Does the standard "Registered\|Voting Member" work, if I need to add multiple user groups? ("Registered" is a bad example to use in a tutorial, as it is both a user group AND an access level).

You can add multiple usergroups using "gids", but this only works on J1.7 Accesslevels aren't assigned to users. They're groups of usergroups.

The "Establish $user object" tutorial, I assume, is the integer database ID in jos_comprofiler.user_id (which is equivalent to jos_users.id)?

Correct.

PS: In your "create-users-through-api" tutorial, the link embedded in "To create a user you must first Include API externally if you are creating..." does not work.

Fixed.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 6 months ago - 12 years 6 months ago #180916 by Yaun
Replied by Yaun on topic Re: Importing existing user data..
I've made some changes to the Joomla REST API to make it more RESTful, and I am now at the point where I need to use it..

However, while your tutorials nicely show how to create and load a single user, based on ID, I can't find how to do the following:
*) get a list of all users,
*) get a list of users based on criteria (e.g. block = 0, registered after = 2011-01-01, etc)
*) load a user based on username, for example.

Am I correct in assuming that I can load a user based on username using:

Part of the message is hidden for the guests. Please log in or register to see it.


I'd like a more future-proof method that doesn't rely on my specifying the username field directly - I might as well just be querying the database via mysql!

Ideally, since I'm going to want to send the results back via REST, I'd also like to know if there are methods to encode the results into, for example, xml or json?


Part of the message is hidden for the guests. Please log in or register to see it.



Part of the message is hidden for the guests. Please log in or register to see it.

Please Log in to join the conversation.

12 years 6 months ago #180917 by Yaun
Replied by Yaun on topic Re: Importing existing user data..

krileon wrote:

Probably using "usertype", I guess.

That and gid (gids if J1.7).

Does the standard "Registered\|Voting Member" work, if I need to add multiple user groups? ("Registered" is a bad example to use in a tutorial, as it is both a user group AND an access level).

You can add multiple usergroups using "gids", but this only works on J1.7 Accesslevels aren't assigned to users. They're groups of usergroups.

Indeed, I meant "to add a user to multiple groups".

To confirm: what is the usage of "gids", in this context? Is it to create a user group, or to specify which groups to assign to this user?

Please Log in to join the conversation.

12 years 6 months ago #180924 by krileon
Replied by krileon on topic Re: Importing existing user data..

*) get a list of all users,
*) get a list of users based on criteria (e.g. block = 0, registered after = 2011-01-01, etc)

Below will give you query capability, but will ensure the results give you CB user objects.
$query	=	'SELECT *'
	.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler' );
$_CB_database->setQuery( $query );
$rows	=	$_CB_database->loadObjectList( 'id', 'moscomprofilerUser', array( &$_CB_database ) );

Adding where clauses you can filter it however you like. To filter out blocked users you'll need to join the _users table first.

*) load a user based on username, for example.

You can load by username using the below which will give you a database object (not a cbUser class object, which has getField API), but that's fine as that's all you get with the method you're already using.
$user	=	new moscomprofilerUser( $_CB_database );

$user->loadByUsername( $username )

Please review CB source closely as all this is contained in CBs library files and/or plugin class, plugin foundation, or comprofiler class files. All of which is in CBs administrator component folder.

Am I correct in assuming that I can load a user based on username using:

Should work, but never used that method.

To confirm: what is the usage of "gids", in this context? Is it to create a user group, or to specify which groups to assign to this user?

You specify an array of group ids you want the user to below to (e.g. array( 8, 24 )).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 6 months ago #180946 by Yaun
Replied by Yaun on topic Re: Importing existing user data..

krileon wrote:

*) get a list of all users,
*) get a list of users based on criteria (e.g. block = 0, registered after = 2011-01-01, etc)

Below will give you query capability, but will ensure the results give you CB user objects.

Adding where clauses you can filter it however you like. To filter out blocked users you'll need to join the _users table first.

Right! Thanks for the simplified code. I assume that it'll also be somewhat future-proof against minor database table name and column name changes?

krileon wrote: Please review CB source closely as all this is contained in CBs library files and/or plugin class, plugin foundation, or comprofiler class files. All of which is in CBs administrator component folder.

There's a lot there! It'll take me a while to appreciate the full content, even with NetBeans IDE helping with the navigation and searching.

Please Log in to join the conversation.

12 years 5 months ago #181107 by krileon
Replied by krileon on topic Re: Importing existing user data..

Right! Thanks for the simplified code. I assume that it'll also be somewhat future-proof against minor database table name and column name changes?

For any 1.x release, yes. For CB 2.0 I can't guarantee any compatibility as we're doing some major changes.

There's a lot there! It'll take me a while to appreciate the full content, even with NetBeans IDE helping with the navigation and searching.

Yeah, there's quite a bit of API. It helps to reviewing existing plugins however on usage. Many of the incubator projects use experimental features for example.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.286 seconds

Facebook Twitter LinkedIn