Skouat PayPal most recent donor

Extensions, styles and support for everything else about phpBB

Who else would like kasimi to share the mod?

Yes 🤡
2
100%
No 😭
0
No votes
Maybe 😱
0
No votes
Don't give a hoot 🤣
0
No votes
 
Total votes: 2

User avatar
wads24
Distinguished Donor
Posts: 29
Joined: 26 Aug 2018, 02:16
Location: Idaho

Re: Skouat PayPal most recent donor

Post by wads24 »

kasimi wrote: 23 May 2021, 19:33
  • Latest donor

    In the event skouat.ppde.donors_group_user_add_before, store the latest donor in the config table:

    Code: Select all

    $this->config->set('latest_donor_id', $event['payer_id'] ?: ANONYMOUS);
    Alternatively, you can fetch it from the database on ever page load but remember to cache the query result.

    In the event core.index_modify_page_title, fetch user info for the latest donor and send the data to the template:

    Code: Select all

    $row = $this->user_loader->get_user($this->config['latest_donor_id'], true);
    $this->template->assign_vars([
        'LATEST_DONOR'       => get_username_string('full', $this->config['latest_donor_id'], $row['username'], $row['user_colour']),
        'LATEST_DONOR_COLOR' => $row['user_id'] == ANONYMOUS ? 'inherit' : ('#' . $row['user_colour']),
    ]);
    With this entry in a language file:

    Code: Select all

    'LATEST_DONOR' => 'Thanks to the latest donor <strong>%1$s</strong>',
    you can then render it in your template file, for example:

    Code: Select all

    {{ lang('LATEST_DONOR', LATEST_DONOR, LATEST_DONOR_COLOR) }}
  • Donation amount over the last 30 days

    Code: Select all

    $days = 30;
    $sql_queries = '
        SELECT SUM(CASE WHEN t.settle_amount = 0 THEN t.mc_gross ELSE t.settle_amount END) AS donations_sum
        FROM ' . $this->table_transactions . ' t
        WHERE t.test_ipn = 0
            AND t.confirmed = 1
            AND t.payment_date >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL ' . $days . ' DAY))';
    $result = $this->db->sql_query($sql, 3600);
    $donations_sum = $this->db->sql_fetchfield('donations_sum', 0, $result);
    $this->db->sql_freeresult($result);
    $this->template->assign_vars([
        'DONATE_DAYS'   => $days,
        'DONATE_AMOUNT' => (int) round($donations_sum),
    ]);
    
    With this entry in a language file:

    Code: Select all

    'DONATE_RECEIVED' => 'Donations over the last %1$d days <strong>%2$s</strong>',
    you can then render it in your template file, for example:

    Code: Select all

    {{ lang('DONATE_RECEIVED', DONATE_DAYS, DONATE_AMOUNT) }}
Could you provide instructions what file to open, find and replace it add before or after...?

I'm not sure which files to make edits.
I am a crazed lunatic that has desires... :lol: :lol: :D
User avatar
wads24
Distinguished Donor
Posts: 29
Joined: 26 Aug 2018, 02:16
Location: Idaho

Re: Skouat PayPal most recent donor

Post by wads24 »

Skouat just replied to my post on phpbb.
Skouat wrote:Hi,
You have to create your own extension that will use/call data provided by PPDE.
You don't have to change any code in PPDE.
That's why Kasimi requested to add 2 events in my extension.
Not sure how to create my own extension though.
I am a crazed lunatic that has desires... :lol: :lol: :D

Who is online

Users browsing this forum: CCBot [Bot] and 0 guests