Page 2 of 2

Re: Notifications

Posted: Wed Jul 20, 2016 10:51 pm
by 3Di
Aurelienazerty wrote:I forgot that, so it's not good thing to make an extension for the moment...
If you are coding an extension that will work only for 3.1.x then go ahead.
Instead if you are coding an extension that aims to be 3.1/3.2 compatible you should code some things more, it is something I recall has been already discussed here.

Re: Notifications

Posted: Sat Dec 17, 2016 4:50 am
by kinerity
Question - how do I show notifications to users who only have a certain permission? Here is my current find users function:

Code: Select all

public function find_users_for_notification($data, $options = array())
{
    // Grab all registered users (excluding bots and guests)
    $sql = 'SELECT user_id
        FROM ' . USERS_TABLE . '
        WHERE user_type <> ' . USER_IGNORE;
    $result = $this->db->sql_query($sql);

    $users = array();
    while ($row = $this->db->sql_fetchrow($result))
    {
        $users[$row['user_id']] = array('');
    }
    $this->db->sql_freeresult($result);

    return $users;
} 

Edit: Fixed. For those wondering, I had to add the following to my notification file:

Code: Select all

protected $permission = 'm_approve';

public function is_available()
{
    $has_permission = $this->auth->acl_getf($this->permission, true);

    return (!empty($has_permission));
} 
I then had to modify my functions so it looked like this:

Code: Select all

public function find_users_for_notification($data, $options = array())
{
    $options = array_merge(array(
        'ignore_users'  => array(),
    ), $options);

    // Grab users that have permission to approval articles
    $user_ary = $this->auth->acl_get_list(false, $this->permission, false);
    $users = (!empty($user_ary[0][$this->permission])) ? $user_ary[0][$this->permission] : array();

    if (empty($users))
    {
        return array();
    }

    return $this->check_user_notification_options($users, $options);
} 

Re: Notifications

Posted: Thu Feb 09, 2017 4:55 pm
by Steve
rxu wrote:
Sat Aug 30, 2014 1:20 pm
Here's a brief guide to give an initial direction about creating notifications in extensions.
Thank You, very usefull :D

Re: Notifications

Posted: Sun Jun 09, 2019 3:12 pm
by Aurelienazerty
rxu wrote:
Sat Aug 30, 2014 1:20 pm
Here's a brief guide to give an initial direction about creating notifications in extensions. I don't claim to its absolute correctness as I'm just describing steps I followed myself to make it work somehow.
Thank's for this tutorial. As phpbb extension change between 3.1 and 3.2 is this tutorial is deprecated ?

Re: Notifications

Posted: Sun Jun 09, 2019 4:47 pm
by rxu
Some things were changed I guess. Well, now you can get phpBB Skeleton Extension and generate notification boilerplate files you need.