changyy / osTicket-plugins-Extra-Frontend-Resources

Adding Extra Frontend Resources
MIT License
1 stars 0 forks source link

Only for Administrator, not for Staff. #1

Open Cm-8 opened 3 weeks ago

Cm-8 commented 3 weeks ago

Hi,

I tried your plugin and I have to thank you for the great work you did. It was very useful for me.

However, I noticed that adding the code for the staff only works if the agent is an admin, it does not work if the agent is a normal operator (not admin).

Do you understand this or am I doing something wrong?

Obviously I would not like to provide administrator privileges to all agents who answer tickets.

Thanks

Cm-8 commented 3 weeks ago

Here: https://github.com/changyy/osTicket-plugins-Extra-Frontend-Resources/blob/main/extra-frontend-resources/extraFrontendResourcesPlugin.php

on line 19, instead of:

                    if (!$thisstaff || !$thisstaff->isAdmin())
                        return;

                    if ($ost) {
                        $ost->addExtraHeader(ExtraFrontendResourcesPlugin::$frontendResources);
                    }

Isn't it better:

                    if ($thisstaff && $thisstaff->isStaff() || $thisstaff->isAdmin()) {

                        if ($ost) {
                            $ost->addExtraHeader(ExtraFrontendResourcesPlugin::$frontendResources);
                        }

                    } else 
                    return;
changyy commented 3 weeks ago

Thank you for your feedback.

I've made a request to the osTicket development team about this app:

I would like to divide front-end development into the following categories:

Reference: https://github.com/osTicket/osTicket/pull/6735/commits/db3337d6e3af90f70b84257dc8babe6449fd2da4

Therefore, it can achieve the goal of providing services only to administrators, such as services through paid APIs.

If you are still interested in this feature, please add some comments to these requests to let the development team know about these needs, thank you

changyy commented 3 weeks ago

Here: https://github.com/changyy/osTicket-plugins-Extra-Frontend-Resources/blob/main/extra-frontend-resources/extraFrontendResourcesPlugin.php

on line 19, instead of:

                    if (!$thisstaff || !$thisstaff->isAdmin())
                        return;

                    if ($ost) {
                        $ost->addExtraHeader(ExtraFrontendResourcesPlugin::$frontendResources);
                    }

Isn't it better:

                    if ($thisstaff && $thisstaff->isStaff() || $thisstaff->isAdmin()) {

                        if ($ost) {
                            $ost->addExtraHeader(ExtraFrontendResourcesPlugin::$frontendResources);
                        }

                    } else 
                    return;

ref: https://github.com/RockefellerArchiveCenter/osTicket/blob/base/include/class.staff.php#L639C14-L639C21

Does this meet your requirements?

                    if (!$thisstaff || !$thisstaff->isActive())
                        return;

                    if ($ost) {
                        $ost->addExtraHeader(ExtraFrontendResourcesPlugin::$frontendResources);
                    }
Cm-8 commented 3 weeks ago

Your modification and mine both work fine, now the code is added for both the administrator agent and the basic agent and not for the user who logs in.

In my case your plugin is useful for adding IA scripts to OsTicket, I don't need the custom header for the customer area but I'll try to follow up anyway.