programatically hide button in Toolbar

Permalink
I have in my concrete5 toolbar additional buttons which take me to file manager, sitemap and a manual. But I don't want our editors in the file manager, only administrators. In the controller of the button I simply try make it visible only for admins and superadmin.

I have:

<?php
namespace Concrete\Package\ExtendedToolbar\MenuItem\FilemanagerBtn;
class Controller extends \Concrete\Core\Application\UserInterface\Menu\Item\Controller
{
     $u = new user();
     $g = Group::getByName('Administrators');
   if ($u->inGroup($g)||$u->isSuperUser()) {
    public function displayItem()
    {
        return true;
    }
}


But does not work. Do I have to do it the other way around? Like hiding the button for the editors?

Thanks.

helvetica
 
mnakalay replied on at Permalink Reply
mnakalay
<?php
namespace Concrete\Package\ExtendedToolbar\MenuItem\FilemanagerBtn;
class Controller extends \Concrete\Core\Application\UserInterface\Menu\Item\Controller
{
    public function displayItem()
    {
         $u = new user();
         $g = Group::getByName('Administrators');
         if ($u->inGroup($g) || $u->isSuperUser()) {
            return true;
         }
    }
}
helvetica replied on at Permalink Reply
helvetica
Thank you.
Now I get this error:
"Class 'Concrete\Package\ExtendedToolbar\MenuItem\FilemanagerBtn\user' not found"

I guess I messed up something. The ortic toolbar works probably only as is.
mnakalay replied on at Permalink Reply
mnakalay
no, the problem is I copied your code as you wrote it and it should be new User() with a capital U not new user()
helvetica replied on at Permalink Reply
helvetica
Same error, - this time with a capital U in user.

Perhaps something with "else" statement?
mnakalay replied on at Permalink Best Answer Reply
mnakalay
Oh yes sorry, I forgot to tell you to use the resource.

So add one line just after the namespace and before the class name like this
namespace Concrete\Package\ExtendedToolbar\MenuItem\FilemanagerBtn;
use Concrete\Core\User\User;
class Controller extends \Concrete\Core\Application\UserInterface\Menu\Item\Controller
helvetica replied on at Permalink Reply
helvetica
Nour, thanks for all the the hints.
After adding User to the ressource I got an error again of not finding class of "Group", so I checked the syntax in the API.
Now, I added "Group" to ressource an finally it works.

<?php
namespace Concrete\Package\ExtendedToolbar\MenuItem\FilemanagerBtn;
use Concrete\Core\User\User;
use Concrete\Core\User\Group\Group;
class Controller extends \Concrete\Core\Application\UserInterface\Menu\Item\Controller
{
    public function displayItem()
    {
         $u = new User();
         $g = Group::getByName('Administrators');
         if ($u->inGroup($g) || $u->isSuperUser()) {
            return true;
         }
    }
}
designbureau replied on at Permalink Reply
hi cat,
if this is part of the blinkbox package please share. we don't have the toolbar extension included.
thanks.
blinkdesign replied on at Permalink Reply
blinkdesign
hi,
Its supported in v. 1.0.1 and will work only above concrete5 v.8.2.x
If your installation needs to be updated, please contact us.
The original toolbar package was written by Remo, you can download and adjust it to your needs.
https://github.com/ortic/ortic-button...
designbureau replied on at Permalink Reply
hello blinkers
Toolbar works, but the themename in the upper left corner has dissapeared. What did I do wrong?
stef
blinkdesign replied on at Permalink Reply
blinkdesign
You have to add it in your white_label array as: 'logo' => 'text', and 'name' => 'text'
/application/config/concrete.php
designbureau replied on at Permalink Reply
Thanks, but unfortunately it's not working. Can you provide the PHP file please.
stef
blinkdesign replied on at Permalink Reply
blinkdesign
Your concrete5 v8.2 and theme v.1.0 was originally installed on a bitnami stack, running on linux.
You mentioned that you run it on a website, working with ipad. I guess safari doesn't read 'logo' => 'themename', you have to specify an image, best would be a SVG.
try this:

<?php
return array(
    'white_label' => array(
        'background_url' => 'path/to/your/backgroundimage.jpg',
   'logo' => 'path/to/your/logo.svg',
        'name' => 'themename'
    )
);
blinkdesign replied on at Permalink Reply
blinkdesign
stef,
if there are more questions about whitelabelling you should open a separate thread.
since v.8.5 is out, an update to your installation will be done in the coming weeks.