Separation the actions


I wanna create the admin panel as a module. It’s rather simple. I have four parts in it: movies, photos, articles and news. Each of these parts has three actions: edit, add, delete ( and maybe move ). In url it must looks like:

It’s only for admin panel. But for diplaying on website we need some more action ( for example for the photos: view, size in, download … ).

And all of this placed in one controller - in PhotosController. But I want to separate the admin part from users part, place ones in different controllers. All admin actions in AdminController, and others in appropriate controllers: PhotosController, MoviesController, etc.

But in this case I faced the problem. So we have action movieAction in AdminController, and we need at least three additional actions for this action: add, edit, move, list… And I dont know the right way to do this. I have only one idea is place the switch construction in each action:

public function movieAction() {

	switch ( $_GET['subaction'] ) {

		case 'add':




		case 'edit':








But it looks terrible :lol:

Is there any other ideas for realize it?

You are complicating it.

Why not just have a controller say PhotosController and let it have it’s own admin action i.e. PhotosController::actionAdmin() and do the same for other controllers.

If you must have your admin actions under one controller after that, consider using CController::forward();

You can create a module (read the doc because it not that simple) for admin.

In a module you will have other controllers for movies, photos, articles and news that will be accessed like admin/photos, admin/movies and so on.

So the controller in the main pool will be photos, with actions like photo/view, photo/download and so on.

In admin you will have actions like admin/photo/edit, admin/photo/delete.

Another nice stuff in doing modules, is that in the AdminModule.php you can put a security check, for forbit the entire module to anyone is not allowed. That avoid the problems that can happen if you forget to forbid a single action (is an additional check).

And, more and more interesting, I guess you can use the url-rewriting for access to admin module like

zaccaria, thank you very much! I like this way and I’ll try to realize it :)

P.S. А, так вы из Москвы :) Спасибо!

@frantic: why don’t use RBac for that? I mean one action for one thing do to and assign permissions to those actions.