Jump to content

Recommended Posts

Posted

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.

Posted

@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; ?>

 

Posted

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 :) )

 

 

Posted
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.

Posted

From the view you can access any Blesta class is loaded by default like Session .

if the admin_*.php files was extending the admin_controller.php , you can set this in only 1 file .

 

 

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...