0

Hi all guys,

I want to do, for the administrators, a page where are displayed all the "routes" regarding the pages etc.
This is the html markup:

<?php
/**
 * @var IV_View_Base $this
 */
?>

<table class="table table-bordered" width="100%">
    <tr>
        <td>
            <table width="100%">
                <tr>
                    <th width="13%">Path</th>
                    <th width="13%">Module</th>
                    <th width="13%">Controller</th>
                    <th width="13%">Action</th>
                    <th width="13%">Access Role</th>
                    <th width="13%">Compare Operator</th>
                    <th width="9%">Submit</th>
                </tr>
            </table>
        </td>
    </tr>
    <?
    $aRoutes = $this->getValue( 'aRoutes' );
    if( count( $aRoutes ) == 0 ) { ?>
        <tr>
            <td colspan="6">No routes found!</td>
        </tr>
    <? } else {
        /**
         * @var Default_Model_RouteEntity $oRoute
         */
        foreach( $aRoutes as $oRoute ) {?>
            <tr><td>
                    <form method="POST" id="my_form"></form>
                    <table width="100%">
                        <td width="13%">
                            <input type="text" value="<?=$oRoute->getPath(); ?>" />
                        </td><td width="13%">
                            <input type="text" value="<?=$oRoute->getModule(); ?>" />
                        </td><td width="13%">
                            <input type="text" value="<?=$oRoute->getController(); ?>" />
                        </td><td width="13%">
                            <input type="text" value="<?=$oRoute->getAction(); ?>" />
                        </td><td width="13%">
                            <input type="text" value="<?=$oRoute->getAccessRole(); ?>" />
                        </td><td width="13%">
                            <input type="text" value="<?=$oRoute->getRoleCompareOperator(); ?>" />
                        </td><td width="9%">
                            <button type="button" class="btn btn-default btn-sm">Edit</button>
                        </td>
                        </tr>
                    </table>
                </td></tr>
        <? }
    } ?>
</table>

After that, I need to create a controller..Something like the administrator can modify the ie. "permission" field and when he save it, it remains for sure saved :P .
How do I create the controller for that?

Could anyone help me?

Thank you in advance.

EDIT:

This is the controller:

class Admin_Controller_Cms extends IV_View_Base {

    public function routesAction() {
        $this->assign( 'aRoutes', Default_Model_RouteEntity::getAllRoutes() );
        $this->renderTemplate( 'cms/routes.phtml' );
    }

Edited by gianluzzz

3
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by veedeoo
0

I am giving you my login controller code.I think this will help You little bit.But I am using codeigniter.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {

    public function __construct(){
    parent::__construct();
     $this->load->model('common_model');
}
// ::::::::::::::::::::::::::::::::::::::::::::::::::

    public function index()
    {
        $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email');
        $this->form_validation->set_rules('password', 'password', 'trim|required');
        if ( $this->form_validation->run() == FALSE )
            {
              $this->load->view('login_form');
            }

        else 
           {
             $email                     =       $this->input->post('email');
             $password                  =       $this->input->post('password');
             $table                     =       'users';
             $where                     =        array('user_email'=>$email,'user_password'=>$password);
             $check=$this->common_model->check_admin($table,$where);
             if($check->num_rows()>0)
            {
             $row                       =        $check->row();
             $user_id                   =        $row->user_id;


             $id        =    $this->session->set_userdata('user_id',$user_id);
             echo "Congratulation! You Are Login";
             redirect('login/manage_user/'.$user_id);
             }
              else
             {
              $this->session->set_flashdata('msg', 'Invalid Username or Password..!!!');


             redirect('login');

             }
            }   
           }

        // ::::::::::::::::::::::::::::::::::::::::::::::::::

        function manage_user($user_id){

        $res       =        $this->common_model->select_where('*','users',array('user_id'=>$user_id));
        $data['result']     =   $res->row();

        $this->load->view('header_new',$data);


        }

        // ::::::::::::::::::::::::::::::::::::::::::::::::::

         function register(){

        $this->form_validation->set_rules('user_email', 'Email', 'trim|required|valid_email');
        $this->form_validation->set_rules('user_password', 'password', 'trim|required');
        $this->form_validation->set_rules('user_name', 'Name', 'trim|required');
        if ( $this->form_validation->run() == FALSE )
            {

                  $this->load->view('user_register');

            }

        else 

        {
        $data['user_email']                  =               $this->input->post('user_email');
        $data['user_password']               =               $this->input->post('user_password');
        $data['user_name']                   =               $this->input->post('user_name');
        $this->common_model->add_user();
       $id   =   $this->db->insert('users',$data);
        echo $id;
        redirect('login/manage_user/'.$id);
        }



    }

}
?>
0

@gianluzzz,

can you please let the forum members, which MVC framework you are currently using?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.