SOLVED Assign Device to User

Status
Not open for further replies.

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
When setting up devices for provisioning, I've been assigning them to users on our system in hopes of allowing them to customize certain options for the device. However, I have yet to find any location in FusionPBX that actually uses this assignment. Does anyone know if it is, in fact, used somewhere? Or maybe it's just there for future development?
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,414
376
83
One example is Hot Desking where the extension gets provisioned to the phone the user is currently using. I'm sure someone will correct me if I'm wrong but I don't think you can customise certain device options on a per user basis.
 

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
I don't think that's quite the case... The FusionPBX Doc on Hot Desking talks about logging in at the phone, not by the admin setting the "user" value for the device. However, that would be a pretty nice feature... If a user is assigned multiple extensions, and the environment is setup with provisioning, it would be that many fewer steps for the admin to take to change the assigned lines in the phone's provisioning settings if he/she could just select what user will be using that device, and then FusionPBX does a 'reverse lookup' of sorts to figure out which extensions that user is assigned.

As I've been poking around in the FusionPBX code again, I have not found any part of it that uses the user assignment of the device. So I just made applicable copies of PHP files in the <fusionpbx dir>/app/devices/ folder. Our goal is to allow users to configure the multi-purpose keys on their phones (we already have provisioning set up), so I needed to make copies of only the devices.php, device_edit.php, and device_key_delete.php files (we prepended them with "user_"). Here's a summary of the changes I made (hopefully the line numbers don't change too much in future versions of FusionPBX):
  • devices.php: search for only the devices in the database that are assigned to the current user, and change applicable links to point to the custom pages
    • 57: $sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' and device_user_uuid='".$_SESSION['user_uuid']."') ";
    • 73, 129: $sql .= "where ((";
    • 78, 134: $sql .= ") and device_user_uuid='".$_SESSION['user_uuid']."') ";
    • 226, 237, 243, 249, 260: <a href="user_*.php"...
  • device_edit.php: change applicable links and redirects to point to custom pages
    • 125, 335: header("Location: user_*.php...
    • 585, 1111: <a href="user_*.php"...
  • device_key_delete.php: change redirection header to point to custom page
    • 59, 62: header("Location: user_*.php...
With these files in place, we gave the "user" group the following permissions under Devices:
  • device_view
  • device_edit
  • device_key_view
  • device_key_add
  • device_key_edit
  • device_key_id
  • device_key_delete
With the web UI ready and the permissions given, we could open it up to the users! We created an additional menu item called "My Devices" that pointed to the /app/devices/user_devices.php file.

Note that this setup is not full-proof, as it doesn't handle cases where there are more permissions given than what I listed above, and it doesn't check to make sure the user is actually assigned to the device they're trying to edit. If you have a nosy user that manages to guess the uuid of someone else's device, they can change what ever settings their user/group has permissions to change.

See also http://www.pbxforums.com/threads/send-provisioning-request-to-phone.491/ for additional modifications to device_edit.php that causes Grandstream phones to re-provision themselves without rebooting.
 
Last edited:
Status
Not open for further replies.