Jump to content

gutterboy

Members
  • Posts

    284
  • Joined

  • Last visited

Posts posted by gutterboy

  1. When I clicked the log out button OR was redirected to the log out page via logging out on our main system is when that error showed.

     

    Full error:

    Files does not exist: D:\Website_Needs\CodeBase\Gimko_V2\billing\app\views\client\bootstrap\client_logout.pdt on line 120 in D:\Website_Needs\CodeBase\Gimko_V2\billing\lib\view.php
    
    Printing Stack Trace:
    #0 D:\Website_Needs\CodeBase\Gimko_V2\billing\lib\controller.php(277): View->fetch('client_logout', NULL)
    #1 D:\Website_Needs\CodeBase\Gimko_V2\billing\lib\dispatcher.php(128): Controller->render()
    #2 D:\Website_Needs\CodeBase\Gimko_V2\billing\index.php(21): Dispatcher::dispatch('/gimko_v2/billi...')
    #3 {main}
    
  2. Any idea why when I change my method name to something else such as "redirect" I get a file doesn't exist error?

     

    ie;

     

    Change this:

        public function getEvents() {
            return array(
                array(
                    'event' => "Users.logout",
                    'callback' => array("this", "run")
                )
                // Add multiple events here
            );
        }
     
        public function run($event) {
            // code here
        }	
    

    To this..

        public function getEvents() {
            return array(
                array(
                    'event' => "Users.logout",
                    'callback' => array("this", "redirect")
                )
                // Add multiple events here
            );
        }
     
        public function redirect($event) {
            // code here
        }	
    

    Basically an error stating a file doesn't exist which comes from line: 120 of lib/view.php

  3. Only a plugin can react to events (this is dictated by the components/events/default/* files) but if you're wanting to call the redirect function from any file I think it should be in a component while the plugin handles the event, loads the component and performs the redirect. I don't think there are any docs on components, just look at a simple one like components/json. It's pretty much just a standard class.

     

    Hmmm ok. Well I guess that leaves me with my initial problem then haha......... guess I'll have to include a config file or something.

  4. I haven't looked at the plugin architecture in Blesta but I don't think they are designed to be called manually. I think it would be better suited for a component, which would be called like this:

    Loader::loadComponents($this, array("MyComponent"));
    $this->MyComponent->redirect($url);
    

    You may want to look at the built in redirect function Controller::redirect() in lib/controller.php

     

    Alright - thanks for your help!

  5. Yeah, don't want to edit the core files or anything - just trying to figure out how this stuff is usually done.

     

    For example this is my plugin handler code:

    class LogoutRedirectPlugin extends Plugin {
    	
        public $url;
    	
        public function __construct() {
            $this->loadConfig(dirname(__FILE__) . DS . "config.json");
        }	
    		
        public function getEvents() {
            return array(
                array(
                    'event' => "Users.logout",
                    'callback' => array("this", "run")
                )
                // Add multiple events here
            );
        }
     
        public function run($event) {
            header('Location: http://localhost/gimko_v2/');
        }	
    	
    }
    

    If I was doing it normally I would just do something like this:

    $logout = new LogoutRedirectPlugin();
    $logout->url = 'http://www.mydomain.com/';
    

    OR...

    $logout = new LogoutRedirectPlugin('http://www.mydomain.com/');
    

    ...and then set it in the constructor.

  6. I just made my very first plugin (very very simple at that haha) and it's basically a plugin that redirects the user after they logout. However I would like to be able to set a member variable for this action so I can pass in the URL I want to redirect to; I can do it via including a config file but I thought updating the member variable would be a better way.

     

    How can I pass in a URL I want it to redirect to such as by setting the value of a member variable or even via a parameter that is passed to a constructor?

     

    Thanks!

  7. wich name has the folder plugin ?

     

    can you lis the structure files name's ?

     

    Inside the plugins folder it goes like this..

    my_plugin/
             controllers/
             models/
             views/
                  default/
             config.json
             my_plugin_controller.php
             my_plugin_model.php
             my_plugin_plugin.php
  8. you need to use setSessionCookie function

    setSessionCookie( string $path = "", string $domain = "", boolean $secure = false )

    then you can get a shared $_SESSION .

    you need to set

    $_SESSION['blesta_id'] = $user->id;

    $_SESSION['blesta_client_id'] = $client->id;

    after the logout destory the session .

     

    Hmmmm..... I'd prefer to do it another way, but if I chose to do it that way where would I put that code? You mean in our main system?

  9.  

    I was referring to an ajax get request. If you want to do a redirect then modify this line in app/controllers/client_logout.php

    $this->redirect($this->base_uri . "login");
    

     

    Hmmm ok, had a look at this. Pretty new to working with the blesta code myself, is there a way I can extend this or something so I can change it so I can pass in a redirect url or something? Because it will vary depending on the environment (dev/test/prod).

  10. If you can't get the user to make a get request and you need it to be seamless then you could get Blesta to redirect users to your main page after logging out. So there will be two redirects upon logging out of your main site.

     

    Well I'm sure I can redirect the user via a GET request to the blesta log out, but not sure how to get blesta to do a redirect after logging them out?

  11. I think that just as you redirect the client to a login url (or make a get request), you would do the same but use the logout url.

     

    If I just redirected them to the logout URL then that's where they would end; I need the process to be seamless so they end up back on the main page of the site - which is where they are sent now when they log out.

  12. It doesn't look like this method is designed to be called via the API. You would need to instantiate a Session object and select the users session using their session ID, which will be stored in a cookie on the users computer. You could search through the session data on the DB for the client id but it would be messy.

     

    Thanks for the reply.

     

    Basically what I am doing is I am using the shared login plugin cody made to log the user into Blesta at the same time as they log into our main site, so when they log out of our main site I want to log them out of Blesta as well.

  13. Ok, seems that was because I was sending it to plugins and not plugin; however I fixed that but now I get a blank page when I am redirected to the blesta URL.

     

    Nvm...... seems it was because the user was using their email as the login and not the username. All fixed now. :)

×
×
  • Create New...