I am trying to create a user with all info sent to createUser (username, password, fullname, etc) but couldn't find a way to make the user locked (can't change password), is there a way to do this?
On a side note, when I delete users (through site admin -> users) that have been created through GalleryEmbed::createUser(), I cannot create the same user again through GalleryEmbed::createUser() (I get a STORAGE_FAILURE or COLLISION). I'm guessing this is because the entry already exists in g2_ExternalIdMap.
Would I simply be able to add in some code to delete the entry in g2_ExternalIdMap when a user gets deleted?
Is there other places that would need to be updated?
Thanks,
cOwMoO
Posts: 32509
no, createUser won't lock the user.
if you want to lock the user, load the user object after creating it, acquire a write lock (list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($use->getId())) on the object.
then set the user-locked status with $user->setLocked(true); save it with $user->save(); and then release your write lock with GalleryCoreApi::releaseLocks($lockId);
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 20
Thanks for the response valiant, worked like a charm.
For reference, here's the code I used:
Anyone know about the other question in my first post? It seems like I should just be able to delete the entry from g2_ExternalIdMap, is there an API I can use for this? I'm hesitant to manually edit the database.
cOwMoO
Posts: 32509
see:
http://sourceforge.net/tracker/index.php?func=detail&aid=1274398&group_id=7130&atid=107130
you should be deleting users with GalleryEmbed::deleteUser().
and if that's not an option, you can delete rows from the externalIdMap with GalleryCoreApi::removeMapEntry('ExternalIdMap', array('externalId' => $id, 'entityType' => 'GalleryUser'));
or alternatively with the 'entityId' => $g2UserId.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 20
Thanks again valiant, always appreciated.
cOwMoO