0

I am an absolute newbie in the world of Yii and MVC. My question is : Say if I have made a CRUD of some model and I have modified the "_form.php" partial to be used from some place else, for example a comment form which is used from the "post" view, and for example if my link for the creation of comment is :

http://localhost/example/comment/create

How do I stop this page from being accessed and only be called from the view of the "posts" page only?

Would I have to use RBAC for this? Is there any other method? Using "GET" methods maybe?

tereško
  • 58,060
  • 25
  • 98
  • 150
Sankalp Singha
  • 4,461
  • 5
  • 39
  • 58
  • You should really read some basics before asking questions. There is [very good guide for yii](http://www.yiiframework.com/doc/guide/) or [this wiki with plenty resources](http://www.yiiframework.com/wiki/397/the-complete-beginner-s-study-guide-for-the-yii-framework/) –  May 02 '13 at 14:10
  • Like I said I am still learning and I tend to learn fast by delving into application making. – Sankalp Singha May 02 '13 at 14:30
  • Thats why i posted some usefull links for you. In short, you can just remove actionCreate from your comment controller. –  May 02 '13 at 14:32

1 Answers1

0

You can try checking if the referrer page is the one you want, using getUrlReferrer() or the magic property urlReferrer:

http://www.yiiframework.com/doc/api/1.1/CHttpRequest#getUrlReferrer-detail

e.g.:

if(preg_match('/post\/view/', Yii::app()->request->urlReferrer) === 1) {
    // do something
}

Place this in your comment/create action.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260