Welcome Guest, Not a member yet? Register   Sign In
MY_Controller
#4

[eluser]blasto333[/eluser]
I have read it, I am extending the controller class in general, thats why they were in MY_Controller.php to begin with. The controller classes in this file are not used in the application as a normal controller would. These are just base controller classes that the real controllers extend.

It might make more sense if I show you the full code:

MY_Controller.php
Code:
<?php
require_once ("Secure_Area.php");
require_once ("Person_Controller.php");
?>

Secure_Area.php
Code:
<?php
class Secure_Area extends Controller
{
    /*
    Controllers that are considered secure extend Secure_Area, optionally a $module_id can
    be set to also check if a user can access a particular module in the system.
    */
    function __construct($module_id=null)
    {
        parent::__construct();    
        
        if(!$this->Employee->is_logged_in())
        {
            redirect('login');
        }
        
        if(!$this->Employee->has_permission($module_id,$this->Employee->get_logged_in_employee_info()->person_id))
        {
            redirect('no_access/'.$module_id);
        }
        
        //load up global data
        $logged_in_employee_info=$this->Employee->get_logged_in_employee_info();
        $data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
        $data['user_info']=$logged_in_employee_info;
        $this->load->vars($data);
    }
}
?>

Person_Controller.php
Code:
<?php
require_once ("interfaces/iPerson_Controller.php");
abstract class Person_Controller extends Secure_Area implements iPerson_Controller
{
    function __construct($module_id=null)
    {
        parent::__construct($module_id);        
    }
    
    /*
    This returns a mailto link for persons with a certain id. This is called with AJAX.
    */
    function mailto()
    {
        $people_to_email=$this->input->post('ids');
        
        if($people_to_email!=false)
        {
            $mailto_url='mailto:';
            foreach($this->Person->get_multiple_info($people_to_email)->result() as $person)
            {
                $mailto_url.=$person->email.',';    
            }
            //remove last comma
            $mailto_url=substr($mailto_url,0,strlen($mailto_url)-1);
            
            echo $mailto_url;
            exit;
        }
        echo '#';
    }
    
    /*
    Gets one row for a person manage table. This is called using AJAX to update one row.
    */
    function get_row()
    {
        $person_id = $this->input->post('person_id');
        $data_row=get_person_data_row($this->Person->get_info($person_id),$this);
        echo $data_row;
    }
        
}
?>


Messages In This Thread
MY_Controller - by El Forum - 10-19-2008, 05:56 AM
MY_Controller - by El Forum - 10-19-2008, 06:00 AM
MY_Controller - by El Forum - 10-19-2008, 06:36 AM
MY_Controller - by El Forum - 10-19-2008, 06:40 AM
MY_Controller - by El Forum - 10-19-2008, 07:10 AM
MY_Controller - by El Forum - 10-19-2008, 10:42 AM
MY_Controller - by El Forum - 10-19-2008, 03:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB