horst Posted December 10, 2015 Share Posted December 10, 2015 (edited) ALIF - Admin Links In Frontend EDIT: latest version update with PHP 8 fixes on 05. Nov 2023 (!) The version now is 1.1.9 (!) This module combines some of the admin links that we want to use on the frontpages sometimes. It is a comfortable and easy way to do so. After you have installed and configured the module, you can inject the links into the frontpage with code like this in a template file: echo $modules->isInstalled('AdminLinksInFrontend') ? $modules->get('AdminLinksInFrontend')->render() : ''; . Credits: The comfortable Javascript Color Picker in the Configpage comes from Jan Odvarko (http://jscolor.com). Many thanks for this! * Toolbar The toolbar can be positioned by css values for top/bottom and left/right. It can expand in vertical or horizontal direction. The buttons are links to the PW admin, for logout, or for editing the page in admin, or informational ones. All settings, including the colors, can be defined in the modules config page. This is available for all PW versions from PW 2.3 up to now. Depending on how you configure this part, it can be used for authors and editors too, maybe. * Import / Export Settings It has the possibility to export and import its settings via two textarea fields. When importing settings, you get a second screen where you can select which settings you want to import. * One-click User Account Switcher For PW versions 2.6.8+, there is one really nice function available, that I use when developing / testing sites with different user / roles. A fast User-Account-Switcher that lets you view the same page from different user accounts with only one click. To enter this mode, you need to login as a superuser one time, and the feature needs to be enabled in the module of course. After that, you can log out, login with different user roles, etc. At least the toolbar buttons for the User-Account-Switcher will stay visible for you. This is session based. There is also an extra button with a trash can and the text "Session", that helps you to leave this mode once you are finished. As you can see in the screenshot, after clicking "guest", I was logged out, but a regular login button, a warning for debug mode and my three defined buttons for user accounts are available. When clicking another user button I login with this account. Very handy. ATTENTION! The use of the One-click User Account Switcher is mainly intended for dev sites, not for public sites! You should be aware that there is a huge security risc when using this feature on public reachable sites! We completly leave ProcessWires comfort zone in regard of security, - and the only thing between your site and potentially hackattacks is this module. (Oh mom, - what have I done?) PW 2.6.8+ has a comfortable function for admin tasks, that let us log into different user accounts via API without using passwords. This module uses this function! All data that is needed during a User Account Switcher session is stored in the session data on the server. So, if someone steel your session cookie, there is potentially risc that he can login as a superuser, depending of the user account buttons you have in your admin links collection! To prevent SessionHijacking, the module can be bound to a single IP address, it uses a fingerprint depending of IP(s) and UserAgent string. And you need to define a max time to live in minutes between 2 and 60, a User Account Switcher session may run. A User Account Switcher session only can be initialized by a Superuser who also explicitly has set a permission called 'alif-user-account-switcher', what is defined by the module, when installing it. So, the prefered way to use this module is, to enable and use the User Account Switcher while the site is unpublic, and before it goes public, remove the permission from the superuser role. This way, you can use its menu function, but not the UAS anymore. On a sidenote, for those rare cases where multiple superusers simultaneous developing on a site and want to use the ALIF, but the UAS should be used only by one, you can leave the 'alif-user-account-switcher' permission removed from the superuser role, but need to assign the role 'alif-superuser' to the single user account. This way, only that single superuser has the permission for UAS, whereas all other superusers doesn't have it. . . * The Configpage * Online demo I have pasted it into this old site and enabled it to be present every time (when the site is in demo mode only!). So, it is an earlier state, but the switcher is functional there: http://pwlaf.biriba.de/dbinfo/ * Download From our modules directory or from github repo Edited November 5, 2023 by horst 31 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted December 10, 2015 Share Posted December 10, 2015 I like it first ! 1 Link to comment Share on other sites More sharing options...
Gideon So Posted December 11, 2015 Share Posted December 11, 2015 This is very nice. Gideon 1 Link to comment Share on other sites More sharing options...
iNoize Posted December 11, 2015 Share Posted December 11, 2015 pretty cool 1 Link to comment Share on other sites More sharing options...
Nicolas Posted December 14, 2015 Share Posted December 14, 2015 Fantastique ! What i see is what i like. 1 Link to comment Share on other sites More sharing options...
horst Posted December 14, 2015 Author Share Posted December 14, 2015 (edited) It's now on Github: https://github.com/horst-n/AdminLinksInFrontend After aproval in the modules directory, I will update the post here. Please, re-read the first post. It is updated with the release announcement and a more detailed explanation of all features. Edited December 15, 2015 by horst 3 Link to comment Share on other sites More sharing options...
horst Posted December 15, 2015 Author Share Posted December 15, 2015 (edited) Have seen that it was mentioned in last ProcessWire Weekly. (sighh, have hurried up with it) I have tested it with PW versions 2.3, 2.4, 2.5, 2.6, 2.7 and with PHP 5.3 and 5.4. It works good from PW 2.4+ up! With PW 2.3, the Javascript Color Picker doesn't function. But 2.3 is really old and if someone has maintained a site until now without ALIF, he will do it fine in future too. Only thing I want to know is: in wich PW version was "showIf" introduced to show / hide Inputfields in the admin? Would be nice if someone can point me to that. So, it is ready for the masses now! Edited December 15, 2015 by horst 5 Link to comment Share on other sites More sharing options...
horst Posted December 17, 2015 Author Share Posted December 17, 2015 Added another little tool to the box that I sometimes use to detect best breakpoints for mediaqueries. A little Javascriptbox that displays the dimensions of body and a configurable custom container (by ID). What dimensions are shown, offsetWidth, ClientWidth, ScrollWidth, is dynamically configurable in the Top of the JSbox: To enable / disable it, select or drop the button in the config page, and, optionally, type in the id of a custom container. 5 Link to comment Share on other sites More sharing options...
horst Posted December 23, 2015 Author Share Posted December 23, 2015 One more Button, for: OpCache status If OpCache is enabled on a site, it includes a new button and add an admin page for viewing the opcache status. The script for showing this is taken from, and credits go to: Rasmus Lerdorfs. See github repo: https://github.com/rlerdorf/opcache-status Link to comment Share on other sites More sharing options...
horst Posted February 7, 2016 Author Share Posted February 7, 2016 Successfully tested ALIF with PW 3.0 and set the version to 1.0.0 stable now. 6 Link to comment Share on other sites More sharing options...
szabesz Posted February 7, 2016 Share Posted February 7, 2016 Hi, First time I have installed it, mainly to see what the button "Debugmode" does. It does not do anything: href='javascript:;' Am I missing something? Link to comment Share on other sites More sharing options...
horst Posted February 7, 2016 Author Share Posted February 7, 2016 This is a pure info icon. It (only) recommends you that you have $config->debug set to true! So, maybe not that useful in develoment mode, but later, if you use a small set of admin links for editors too, it is useful to be rmembered to turn out debug mode when finished something on a production site. Link to comment Share on other sites More sharing options...
szabesz Posted February 7, 2016 Share Posted February 7, 2016 Aha, I see now! Thank you! 1 Link to comment Share on other sites More sharing options...
cstevensjr Posted February 24, 2016 Share Posted February 24, 2016 This morning, I finally had time to install this module. I am blown away to it's usefulness and wish I had made time to look at this a whole lot earlier. Great work, @horst! 3 Link to comment Share on other sites More sharing options...
bernhard Posted February 24, 2016 Share Posted February 24, 2016 hi horst, i can't seem to get the user switcher working... after some setup problems i finally got the user-buttons to display. but when i click on "guest" i am logged out and don't see the user buttons any more. also the "enable login-button" seems to have no effect. can you please help me how i can debug this? thanks! Link to comment Share on other sites More sharing options...
horst Posted February 24, 2016 Author Share Posted February 24, 2016 This morning, I finally had time to install this module. I am blown away to it's usefulness and wish I had made time to look at this a whole lot earlier. Great work, @horst! Thanks Charles! hi horst, i can't seem to get the user switcher working... after some setup problems i finally got the user-buttons to display. but when i click on "guest" i am logged out and don't see the user buttons any more. also the "enable login-button" seems to have no effect. can you please help me how i can debug this? thanks! Bernhard, I'm not sure, but best thing would be, if you can run this locally and use an IDE with debugger. Everything in this regard is Sessionbased. You need to check / debug those functions in the module: public function hookBeforeProcessLogin(HookEvent $event) { public function hookBeforeProcessLogout(HookEvent $event) { public function hookAfterSessionLogout(HookEvent $event) { public function hookAfterSessionLogin(HookEvent $event) { Also I don't know what you mean with: "after some setup problems"? Link to comment Share on other sites More sharing options...
bernhard Posted February 25, 2016 Share Posted February 25, 2016 hi horst, i tried it on a fresh install today and got it working. don't know what was the reason but i'm too busy right now to investigate further Also I don't know what you mean with: "after some setup problems"? i was not sure what all the fields where doing my questions where like this: "select users" what is this doing? is this controlling access? will only users selected here see the switcher? "start UAS session" what is an UAS session?? ok got it now... user account switcher, but i thought that was a technical word i didn't know. and therefore i didn't know what this checkbox is doing at all. i think step by step instructions would be good, like: if you want to show the user switcher proceed as follows: check the box "enable user account switcher select users that should be shown in the switcher-panel check the box to start the user account switcher (UAS) session select the time, how long the UAS should be active (no good english i think) click on "submit" button and go to frontend. the UAS-Panel should show up edit: i think it would help to change the field label from Configure and start the fast User Account Switcher to Configure and start the fast User Account Switcher (UAS) maybe that sounds too much to you, but it was really not clear for me as i did not know anything about the workflow. edit2: maybe a screencast with licecap would have also solved those questions Link to comment Share on other sites More sharing options...
tpr Posted June 16, 2016 Share Posted June 16, 2016 On module install there's a PHP error: Trying to get property of non-object in .../ProcessAdminLinksInFrontend.module:52 Link to comment Share on other sites More sharing options...
tpr Posted June 16, 2016 Share Posted June 16, 2016 Sorry it's me again, 'Warm up opcache with PW files' throws an error here (Tracy): Cannot declare class ProcessWire\InputfieldForm, because the name is already in use 5× PHP Notice: Undefined index: dirname in .../AdminLinksInFrontend/libs/hn_basic.class.php:1748 21× PHP Notice: Use of undefined constant THOUSAND_SEPARATOR - assumed 'THOUSAND_SEPARATOR' in .../site/modules/AdminLinksInFrontend/libs/opcache.php:60 634× PHP Notice: Use of undefined constant THOUSAND_SEPARATOR - assumed 'THOUSAND_SEPARATOR' in .../site/modules/AdminLinksInFrontend/libs/opcache.php:249 1× PHP Notice: Use of undefined constant THOUSAND_SEPARATOR - assumed 'THOUSAND_SEPARATOR' in .../site/modules/AdminLinksInFrontend/libs/opcache.php:183 Link to comment Share on other sites More sharing options...
horst Posted June 16, 2016 Author Share Posted June 16, 2016 Hhm, looks like the OPCache class is not ready to use with PW3 namespaces. Unfortunately I have no PW3 installl with OPCache installed where I can test it. To the first error, I can say this sounds a bit weird, because I try to get the Page of Admin -> Setup (what is 22) and than checks if it has a children Page with the name of the OP-Cache Viewer. So this should return A) the page if existing, or B) a NullPage object. Both possible returns are objects. So, without able to test, it looks weird. What ID does your Admin Setup Page have? --- I suggest to uninstall the OPCache Viewer and only use the Admin Links In Frontend module until I got solved this. (What may take a while, ) Link to comment Share on other sites More sharing options...
tpr Posted June 16, 2016 Share Posted June 16, 2016 Ok, thanks. Don't worry about the errors, I use this module only occassionally, and I just took a look on the opcache viewer as there's opcache on the server. As for issue No1, maybe there's an extra "children('include=hidden')" that doesn't needed? // original - throws error $p = $this->pages->get(22)->children('include=hidden')->get('name=' . AdminLinksInFrontend::opcPageName); // works $p = $this->pages->get(22)->get('name=' . AdminLinksInFrontend::opcPageName); // in one go $p = $this->pages->get('parent=22, name=' . AdminLinksInFrontend::opcPageName); Admin->Setup has the id of 22 here too. I forgot to mention that it's PW 3.021 here but it seems you figured this out 1 Link to comment Share on other sites More sharing options...
eyeball Posted June 18, 2016 Share Posted June 18, 2016 Thanks for the module! 1 Link to comment Share on other sites More sharing options...
Mikel Posted June 30, 2016 Share Posted June 30, 2016 Hi, Horst, I just tried to install the module, but got 2 error messages right after downloading, regarding: AdminLinksInFrontend.module, line 153 and ProcessAdminLinksInFrontend.module, line 45 In both cases I had to remove the [...] part to get it working: self::$opcEnabled = opcache_get_status();//['opcache_enabled']; I am running PW 3.0.23 in this particular case. EDIT: Ok, now PW tells me why: I need to install PHP 5.4 or greater... Sorry for bothering you! 1 Link to comment Share on other sites More sharing options...
horst Posted July 10, 2016 Author Share Posted July 10, 2016 Have made some updates to ALIF: 1.1.0 fixed a bug in method sanitizeColor() 1.1.1 added detection and a toggle button for TracyDebugger (enable/disable) 1.1.2 more security for User-Switcher, (stays in for cases, where TracyDebugger isn't available) http://modules.processwire.com/modules/admin-links-in-frontend/ 6 Link to comment Share on other sites More sharing options...
adrian Posted November 21, 2017 Share Posted November 21, 2017 On 12/10/2015 at 12:35 PM, horst said: A User Account Switcher session only can be initialized by a Superuser who also explicitly has set a permission called 'alif-user-account-switcher', what is defined by the module, when installing it. Just an FYI, that a recent change to the core might make this impossible to do via the admin:https://github.com/processwire/processwire/commit/7943aa1064204db5415d661312037f1dd4199249 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now