Jump to content

Logged in Staff ID?


Michael

Recommended Posts

Hi guys,

Is there a way to grab the current logged in staff ID in the admin area / client id?

I've tried:

$client->first_name thinking as they use the same table that would work.

$staff->first_name & $admin->first_name trying to see if that works as the above didn't.

Tried grabbing them like:

$staff->staff_id & $admin->staff_id & $staff_first_name & $staff_id & $session->staff_id but none seem to work :o Merci.

Link to comment
Share on other sites

@Mujahed has helped me get this working this guy is a legend :p.

In each controller in /app/controllers/admin_*.php add the following code:

$this->structure->set("blesta_staff_id", $this->Session->read("blesta_staff_id"));

in this function:

public function preAction()
    {

    }

Eg admin_billing.php:

    public function preAction()
    {
        parent::preAction();

        // Require login
        $this->requireLogin();

        Language::loadLang(['admin_billing']);
        $this->structure->set("blesta_staff_id", $this->Session->read("blesta_staff_id"));
    [...]
    }

This allows you to use this command to get the staff_id:

<?php $blesta_staff_id; ?>

 

Link to comment
Share on other sites

if you want only the staff id , you can get it in the PDT files without changing other files .

simply make it like that in your admin template file .

<?php echo $this->Html->ifSet(Session::read("blesta_staff_id")); ?>

and let me ask Blesta team about the admin_controller.php . is not called anywhere, no ?

client_controller.php is called in all client_*.php file , that give us the option to add what we want in that file and is accessible in all client view .

why not also change all admin_*.php file to extend the AdminController instead of AppController ? (just to note this is note a request , is just a question to know something more about blesta :) )

 

 

Link to comment
Share on other sites

22 minutes ago, Blesta Addons said:

if you want only the staff id , you can get it in the PDT files without changing other files .

simply make it like that in your admin template file .


<?php echo $this->Html->ifSet(Session::read("blesta_staff_id")); ?>

and let me ask Blesta team about the admin_controller.php . is not called anywhere, no ?

client_controller.php is called in all client_*.php file , that give us the option to add what we want in that file and is accessible in all client view .

why not also change all admin_*.php file to extend the AdminController instead of AppController ? (just to note this is note a request , is just a question to know something more about blesta :) )

 

 

Think I tried something that I think as the sessions aren't set in the view just the controllers, so we needed to set a variable and there's one controller we could have used: app_controller.php is encoded which is for licensing I believe :).


I use it so I can autoplay my favourite radio station but Callum and Matthew don't get it as they aren't a fan of it lol.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...