This topic is locked
[SOLVED]

How can we set permissions according to user group in Notification API

3/11/2022 2:53:24 PM
PHPRunner General questions
M
muammer author

Hello
How can we set permissions according to user group in Notification API in PhpRunner 10.7 38770 build. Example Code sharing or solution suggestion would be nice.
Notification API is a really nice feature, but it would be even better if it could be used with user group permissions.

Sergey Kornilov admin 3/11/2022

I do not follow. What is the relation between notifications and permissions?

M
muammer author 3/11/2022

https://xlinesoft.com/blog/2021/12/18/version-10-7/ In the feature described on the blog page, it is explained that the notifications can be adjusted according to the desired user. Is it possible to set the same property as groups. function addNotification( $message, $title = null, $icon = null, $url = null, $expire = null, $user = null, $provider = null )

Is it possible to have "$group" instead of "$user" in the code structure you gave as an example on your blog page? Can we allow the groups we want to see the notifications? Please excuse my bad english. I don't know, could I explain?

D
druck281 3/22/2022

Here is an example that I wrote where I wanted to notify two specific user groups. You can arrange the WHERE clause how you want to fit your use.

Good luck!

$currentUser=$_SESSION["UserName"]; //Setting current user to variable for use in the comparison for the "if" statement
$rs = DB::Query("SELECT * FROM trax_ugmembers WHERE GroupID=12 OR GroupID=3"); //Fetch an array of usernames from the given user groups
while($data = $rs->fetchAssoc() )
{
//The "If" statement serves to skip over creating a notification for the user that created the record
if ($data["UserName"] != $currentUser) {
//Calls the Notification API. At testing the makePageLink() function was not producing the $keys value so the URL was hardcoded
addNotification("New Crash Number: ".$values['CrashNumber'], "Crash Added", "glyphicon-send", "pat_CrashNumberAssign_edit.php?editid1=".$values['CAD_Number'], $expire=5, $data["UserName"]);
}
}