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 #319193 by Julien04
Mamamia :-) it's still hard for me ..

In relation to what you have just explained to me, I did:

1 - Filtering of the active request:

Field activity (138)> Activity > Filters

Filter: LIKE

Assets: profile.%. Field.138

I have a great doubt on the operator LIKE, I do not know what it is .. Is this in its place?

2 - Integrate the code into CB Auto Actions

So here I swim .. I have no idea what to do ..

Can you explain me the integration procedure point by point please?

I understood the principle now, but technically I am not competent on this one.

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 #319197 by krileon
The supplied code is for a Code action. So you'd have the below.

Global
Triggers: None
Type: Code
User: Automatic
Access: Everybody
Action
Method: PHP
Code:
Code:
global $_CB_database; $asset = 'profile.%.field.138'; $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(); }

I've already adjusted the $asset to account for your fields id. You'll need to adjust $duration for whatever duration you're wanting.

I highly suggest considering taking some time to learn a little PHP and SQL. CB Auto Actions is a tool that minimizes how much someone has to actually write code as much as possible, but it's just not possible for us to cover every usecase so it's likely you'll need to do more like this in the future.

The above can then be ran on a regular basis using a wget or cURL CRON task using the URL provided under the Global tab. Alternatively you can visit the URL manually every few days if you wanted.


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 - 4 years 5 months ago #319217 by Julien04
Hello !

Thank you for your patience and your sharing.

Indeed, I have very little knowledge in Php and basic SQL .. My intention is to surround myself with a medium term development when my site will regularly generate traffic because I would not have time to devote to learn and master these languages ​​with my professional activities ..

I understand your position and thank you for sharing this code spontaneously because it will allow me to offer real personal development tools to my members! I will not abuse your gift in the future.

So .. I created an action by configuring the Global tab with your data and integrated the PHP code in the Action tab (Method: PHP)

I understood that I could execute it with a CRON task if necessary as for the CRON of Ackeba backup, that's in my strings: p.

When the action was saved, the internal URL was created but when I tested it .. It doesn't work, the content of the wall remains present.

I tried again with another field without success.

I attach the screenshoots of the configuration of the action on the 2 tabs: Global / Action, to be sure that there is no mistake on my part!

Thanks again..

Ps : What access ACL i need to CB Auto Actions Plugin please ?
Attachments:
Last edit: 4 years 5 months ago by Julien04. Reason: postsciptum

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 #319220 by krileon
Enable debug mode and maximum error reporting in Joomla global configuration. Then under the Parameter tab of your auto action enable Debug. Next retry and see if any errors output. It's possible the namespace paths in some of the code need to be adjust, but they should be correct.


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 - 4 years 5 months ago #319222 by Julien04
Ok, i have active debog mod for Joomla and Action.

When i test with url it appears this error message :

Erreur
:: Action 94 :: Code failed. Error: syntax error, unexpected '.'

Thanks !
Last edit: 4 years 5 months ago by Julien04.

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 #319224 by krileon
Ah, there's an extra closing statement in the query. Try the below.

Code:
global $_CB_database; $asset = 'profile.%.field.138'; $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(); }

I didn't test this code. It was just put together as an example from the code provided earlier.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum