onBeforeUpdateUser trigger

16 years 5 months ago #49320 by gsrtek
onBeforeUpdateUser trigger was created by gsrtek
I am not sure if this is the right place to make a suggestion.

I just finished a plugin (it syncs my gallery2 users with CB including the groups).

I congratulate the developers of CB because it was actually very simple.

My only suggestion (which would have made my plugin development a bit quicker) and I think it makes sense in fact I have added (and I hate to hack code).

The onBeforeUpdateUser trigger should also pass the previous state of the user. In fact it is already saved two lines above the triggering. Like I said I added it (but I hate to hack code). In my logic if you have an onBeforeUpdate trigger and an onAfterUpdate trigger the before trigger should have the state prior to changing (maybe I am doing something incorrect or maybe it is a bug)

Any advise is welcomed

Please Log in to join the conversation.

16 years 5 months ago #49323 by beat
Replied by beat on topic Re:onBeforeUpdateUser trigger
Cool that you could make this happen easily :)

Please feel free to share your result with the community (either as post-attachment, or upload as 3pd, pm nant for this), I'm pretty sure you will make quite a few happy, and probably get feedback and improvement proposals. ;)

Just to understand right your proposal:

You suggesting to change:

[code:1] $_PLUGINS->trigger( 'onBeforeUserUpdate', array(&$row,&$rowExtras));[/code:1]

to:

[code:1] $_PLUGINS->trigger( 'onBeforeUserUpdate', array(&$row,&$rowExtras, &$oldRow, &$oldRowExtras));[/code:1]

($oldRow needing to be created) in comprofiler.php

and:

[code:1] $_PLUGINS->trigger( 'onBeforeUpdateUser', array(&$row,&$rowExtras));[/code:1]

to:

[code:1] $_PLUGINS->trigger( 'onBeforeUpdateUser', array(&$row,&$rowExtras, &$previousState ));[/code:1]

in admin.comprofiler.controller.php ?

The idea that this wasn't done initially, is that the old values could be gotten from database, but the above changes make sense and would be backwards-compatible.

If I didn't understand right, please just code-quote your proposed changes :)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

16 years 5 months ago #49324 by gsrtek
Replied by gsrtek on topic Re:onBeforeUpdateUser trigger
Your code looks exactly like mine, so yes that is what I did. I know it could be easily have gotten from the database but, since it already is there why not just pass it along.

Like I said my logic is Before means the state prior to something happening and After well after the state changes in fact the way it is coded at the moment OnBeforeUpdate and OnAfterUpate have exactly the same data.

Yes I will share the plugin after I do a bit more testing. Also I need to make it a bit more generic it was written for my site and I need to remove a few features that probably would just get in other users way.

Also I need to make a few changes so it will work with PHP4 I have some PHP5 code in the plugin (of course unless you are forced to why use PHP4) but I know there are hosting companies especially shared hosting that will not budge from PHP4

I wrote the little plugin (and it is no more than 100 lines of code) because the gallery2bridge (thing) was a nightmare to work with. I would never "knock" anyones efforts (I am sure a lot of work went into it) but all I needed to do was sync my users and groups with Gallery2 and I just could not see having like 1,000's of lines of code that I do not need. Plus the gallery2bridge does not correctly (by their own admission) deal with groups properly. This was a huge problem for me as I have 51,000 joomla members and over 12,000 images and videos in my gallery2.

Please Log in to join the conversation.

16 years 5 months ago #50083 by gsrtek
Replied by gsrtek on topic Re:onBeforeUpdateUser trigger
I need a suggestion:
This plugin is finished and I have completed testing it. I need to add one piece of functionality.

Which is an original sycn. It would be GREAT to add the Gallery2 sync when a CB Joomla Sync is done. I looked at your syncUsers function and unfortunately it does not act as I would have hoped using your own update user function and therefore having the "onAfterUpdateUser" trigger, triggered this would have been perfect.

It makes sense to add the gallery2 sync code to CB as once you install CB you really should not be using anything else to "mess" around with users.

I could write my own sync function but that seems a bit overkill for something that only really needs to be done once.

Suggestions are welcomed
Thanks
Gary

Please Log in to join the conversation.

16 years 5 months ago #50387 by beat
Replied by beat on topic Re:onBeforeUpdateUser trigger
Ok, the existing triggers above have been extended as proposed.

Plus 2 new triggers have been added to the user synchronization in backend:

[code:1]$msg = $_PLUGINS->trigger( 'onBeforeSyncUser', true );
...
$msg = $_PLUGINS->trigger( 'onAfterSyncUser', true );
[/code:1]

for your review.

Thanks for the feedback, it's a clever way for the bridges. :)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

15 years 7 months ago #73334 by dutchadmin
Replied by dutchadmin on topic Re:onBeforeUpdateUser trigger
So, if I untherstand good, this triger is to automaticly sync user ho has login in to CB with Joomla

Oke, for all newbee's it would be nice to explane where you have to add this new triger and in what file you will be able to find it.

We are not all the same as you know and do not have all the same experiance with PHP ;)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.266 seconds

Facebook Twitter LinkedIn