Skip to Content Skip to Menu

[SOLVED] Cb Activity - Clean automaticaly a field every x days ?

  • Julien04
  • Julien04
  • OFFLINE
  • Posts: 234
  • Thanks: 35
  • Karma: 7
4 years 5 months ago - 4 years 4 months ago #318989 by Julien04
Hello,

I want to automatically clean up the content of an activity field every 23 days from the date of publication of an activity.

The global CB Activity configuration allows this but in all fields.

It seems there is no option to do this independently for each field directly.

I tell myself that with the CB action plugin, it may be possible to create an action that would say:

I automatically clean up activities that were posted exactly 23 days ago on field 136 for example.

Can you help me achieve this?

I thank you in advance,

Julien
Last edit: 4 years 4 months ago by beat. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
4 years 5 months ago #318994 by krileon
It will be possible to do this on a per-stream basis in a later release once streams are stored and not dynamically generated. For now there is no option for that. Of course CB Auto Actions can do this assuming you code the entire process yourself. You'd need to pull the database entries, turn them into table objects, and call their delete functions. You can review how this is being code in core CB Activity in the cleanUp function of \components\com_comprofiler\plugin\user\plug_cbactivity\component.cbactivity.php.


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.
The following user(s) said Thank You: Julien04

Please Log in or Create an account to join the conversation.

  • Julien04
  • Julien04
  • OFFLINE
  • Posts: 234
  • Thanks: 35
  • Karma: 7
4 years 5 months ago #319028 by Julien04
Ok Kyle, thanks for the feedback ! I patient and found actually an other way. It's too much for me :D

Have a nice day !

Please Log in or Create an account to join the conversation.

  • Julien04
  • Julien04
  • OFFLINE
  • Posts: 234
  • Thanks: 35
  • Karma: 7
4 years 5 months ago #319177 by Julien04
Hi !

I return to this topic ...: - D

I analyzed the php component.cbactivity.php script and tried to understand how the general cleanup worked but without success.

I understand the principle but not the system: -S.

I'm going to need this function to create a special tool on my site.

Could you please help me set up the system that would allow the cleaning of the content of activity tables every X days with CB Auto Actions?

I thank you in advance !

Julien

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
4 years 5 months ago #319183 by krileon
To make the clean up code stream specific you need to filter the query by asset. By default fields have an asset of profile.USER_ID.field.FIELD_ID. Lets assume your fields ID is 10. Now we need this to apply to every profile for that field and that's done using a wildcard. So you'd have profile.%.field.10. This is then applied to the query using a LIKE operator. Next it should be slimmed down for CB Auto Actions purpose as follows.

Code:
global $_CB_database; $asset = 'profile.%.field.10'; $duration = '-3 DAYS'; $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_activity' ) . "\n WHERE " . $_CB_database->NameQuote( 'asset' ) . " LIKE " . $_CB_database->Quote( $asset ); . "\n AND " . $_CB_database->NameQuote( 'date' ) . " <= " . $_CB_database->Quote( \CBLib\Application\Application::Date( 'now', 'UTC' )->modify( $duration )->format( 'Y-m-d H:i:s' ) ); $_CB_database->setQuery( $query ); $activities = $_CB_database->loadObjectList( null, '\CB\Plugin\Activity\Table\ActivityTable', array( $_CB_database ) ); foreach ( $activities as $activity ) { $activity->delete(); }

Adjust $asset and $duration as needed. For example if your field id isn't 10 change that in the asset. If you want it to delete things older than 5 days instead of 3 then set duration to -5 DAYS.


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 or Create an account to join the conversation.

  • Julien04
  • Julien04
  • OFFLINE
  • Posts: 234
  • Thanks: 35
  • Karma: 7
4 years 5 months ago #319186 by Julien04
Omg Gratitude Kyle !

I try it now !

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum