XF 2.2 Question about modifying an add-on

Dkf

Active member
Sorry if I’m asking in the wrong section.I have two add-ons installed on my forum:

  1. Ads Manager 2 by Siropu
  2. Classified Ads System
Each thread has an advertisement attached to it.

How can I make the "Ads Manager 2 by Siropu" add-on delete the corresponding advertisement when a thread is deleted after it expires?

I found part of the code I need:

Code:
public static function disableExpiredAds()
{
    $ads = self::getAdRepo()
        ->findAdsForList()
        ->ofStatus('active')
        ->hasExpired()
        ->fetch();

    foreach ($ads as $ad)
    {
        $ad->end_date = 0;
        $ad->status = 'inactive';
        $ad->updateExtraData(['notice_sent' => 0]);
        $ad->setOption('process_queue', true);
        $ad->save();

        $notifier = \XF::service('Siropu\AdsManager:Ad\Notifier', $ad, 'expired');
        $notifier->sendNotification();
    }
}

What is the general strategy?
Do I need to somehow call another add-on through the API?
How to implement a function call from another add-on?

Or can I somehow create an SQL query like :
UPDATE xf_xa_cas_ad SET ad_state = 'deleted' WHERE user_id = '12345';
 
Back
Top Bottom