I am a bit confused about how I can exchange information between controllers in CakePHP 2.0. This is basically what I am trying to do.
I have images db table that holds id,name,path, etc.
users table that holds user user, password, etc.
I have a model Image.php, a controller – ImagesController.php, and
views – View/Images/add.ctp View/Images/index.ctp View/Images/view.ctpI have a model User.php, a controller – UsersController.php, and views
– View/Users/index.ctp, View/Users/login.ctp
My View/Images/index.ctp lists all the images that have been uploaded, View/Images/add.ctp lets anyone upload an image
View/Users/login.ctp lets the user log in and if it’s correct info, it sends the user to View/Users/index.ctp
1) How can I make View/Images/add.ctp be accessible only to users who are logged in. Should I redirect them to View/Images/add.ctp with user session information and check if the data is set or how does it work in CakePHP?
2) If I am updating an images table from Images using $this->Image->saveAll($data_s). How can I save some of the data into User table? I have looked at the documentation but a bit confused still.
$this->Image->User. Otherwise, you can include any model in any controller using the$usesattribute or temporarily using theloadModelmethod.