Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP 2.3 Plugin doesn't seem to extend appcontroller
    text
    copied!<p>I've created a plugin called 'IssueTracker', which is located in <code>app/Plugin/IssueTracker</code>. I've created a Controller called <code>Tickets</code> and it is accessible at <code>www.example.com/issue_tracker/tickets/</code>. But, only for logged in users with the rank 'Admin'.</p> <p>That wasn't exactly what I was hoping for, so I added in my <code>Plugin/IssueTracker/Controller/TicketsController.php</code> the following:</p> <pre class="lang-php prettyprint-override"><code>public function beforeFilter() { parent::beforeFilter(); $this-&gt;Auth-&gt;allow('index'); } </code></pre> <p>I hoped that with this piece of code (which I'm using in several other controllers in my <code>app/Controller/</code> that it would inherit from my <code>AppController.php</code> file. The <code>TicketsController.php</code> file extends the <code>IssueTrackerAppController</code> (like this):</p> <pre><code>class TicketsController extends IssueTrackerAppController { //functions goes in here } </code></pre> <p>And in my <code>Plugin/Controller</code> folder I've created the file <code>IssueTrackerAppController</code> which extends the <code>AppController</code>.</p> <p>In my <code>AppController.php</code> file I've allready defined that <code>'index'</code> and <code>'view'</code> are public actions. But, for some reason, it doesn't work in my plugin.</p> <p>Is there something that I'm overseeing? When I access <code>www.example.com/issue_tracker/tickets</code> as a not logged in user (Guest), it tells me that I need to login. If I'm logged in as a user, but not as an Admin, the <code>Auth</code> component won't allow me in and presents the login form.</p> <p>There should be a way to get <code>Auth</code> working in a plugin, right?</p> <p><strong>EDIT</strong> </p> <p>Below is the <code>AppController.php</code> snippet where I've configured Auth:</p> <pre><code>public $components = array( 'Auth' =&gt; array( 'loginAction' =&gt; array('controller' =&gt; 'users', 'action' =&gt; 'login', 'plugin' =&gt; false), 'loginRedirect' =&gt; array('plugin' =&gt; false, 'controller' =&gt; 'ervaringen', 'action' =&gt; 'add'), 'logoutRedirect' =&gt; array('plugin' =&gt; false, 'controller' =&gt; 'ervaringen', 'action' =&gt; 'index'), 'authorize' =&gt; array('controller'), 'flash' =&gt; array( 'element' =&gt; 'error', 'key' =&gt; 'auth', 'params' =&gt; array( 'heading' =&gt; 'Waarschuwing!') ), 'authError' =&gt; 'Je moet inloggen om deze inhoud te bekijken.', ), 'Session', 'DebugKit.Toolbar' ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload