How to redirect all webpages under webroot to login page?

2014-05-15 Thread Sam


I am using cakephp 2.4.5. I would like to redirect all users who have not 
logged in to a login page. I basically followed the instructions here 
http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

In summary, the important part is the following code to AppController.php

public $components = array('Session',
'Auth' = array(
'loginRedirect' = array('controller' = 
'users', 'action' = 'index'),
'logoutRedirect' = array('controller' = 
'users', 'action' = 'login'),
'authError' = 'You must be logged in to view 
this page.',
'loginError' = 'Invalid Username or Password 
entered, please try again.'
));

Any websites with this URL format 
http://localhost/cakephp245/controllers/XXX will be re-directed to the 
login page. However, websites that are located inside webroot with URL that 
looks like thishttp://localhost/TTSH-CP245/app/webroot/XXX will not be 
re-directed to the login page.

How can I get websites located inside app/webroot folder to be re-directed 
to the login page?

Thank you very much.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Redirect all webpages under webroot to login page

2014-05-15 Thread Sam


I am using cakephp 2.4.5. I would like to redirect all users who have not 
logged in to a login page. I basically followed the instructions here 
http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

In summary, the important part is the following code to AppController.php

public $components = array('Session',
'Auth' = array(
'loginRedirect' = array('controller' = 
'users', 'action' = 'index'),
'logoutRedirect' = array('controller' = 
'users', 'action' = 'login'),
'authError' = 'You must be logged in to view 
this page.',
'loginError' = 'Invalid Username or Password 
entered, please try again.'
));

Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
will be re-directed to the login page. However, websites that are located 
inside webroot with URL that looks like 
thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to the 
login page.

How can I force websites located inside app/webroot folder to be re-directed to 
the login page?

Thank you very much.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Deleting an associated HABTM record

2014-05-15 Thread WhyNotSmile
Ok, I'm probably being really dumb here, but I can't figure out how to 
delete an associated record when the association is HABTM.

I have the following:

*Invoice:*

public $hasAndBelongsToMany = array(
'Flag' = array(
'counterCache' = true,
)
);

I can add flags to invoices no problem (just by creating 
$invoice['Flag'][...] and then saving the invoice), but I can't figure out 
how to delete them!

I've tried:
  $this-FlagInvoice-deleteAll( array( 'invoice_id' = $invoice_id, 
'flag_id' = $flag_id ) );
and
  $this-FlagInvoice-deleteAll();

but I get Call to a member function deleteAll() on a non-object 
(presumably for the 'FlagInvoice').

If I add 'FlagInvoice' to the $uses variable at the top of the controller, 
I get the error that the table doesn't exist in the database.

I know I'm missing something really obvious here (I'm pretty certain I've 
even done this before!), but I've looked online, and I can't find an 
answer.  Can anyone help? Thanks!

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP Gallery Plugin

2014-05-15 Thread Hugo Dias
Hi guys,

I created a Gallery plugin for CakePHP 2.x to manage albums and pictures 
for any model.

You can check out the code, features, docs and demo here: 
https://github.com/hugodias/cakegallery

Feel free to send feedbacks :)

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Upgrading from cakePHP version 1.3 to 2.5

2014-05-15 Thread earth
I have a project in cakePHP version 1.3 and i want it to upgrade it 
to cakePHP version 2.5
Please let me know the best way to do this upgrade.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Deleting an associated HABTM record

2014-05-15 Thread Reuben
Since the convention would be for a join table to be flags_invoices 
(alphabetical), the model name might be FlagsInvoice, even though CakePHP 
to automagically generate a dynamic model of FlagInvoice while using the 
HABTM relationship from the Flag or Invoice models.

Though it might be easier to explicitly define the FlagInvoice model, as 
per the example in hasMany through (The Join Model) 
(http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasmany-through-the-join-model)

Regards
Reuben Helms

On Friday, 16 May 2014 01:43:58 UTC+10, WhyNotSmile wrote:

 Ok, I'm probably being really dumb here, but I can't figure out how to 
 delete an associated record when the association is HABTM.

 I have the following:

 *Invoice:*
 
 public $hasAndBelongsToMany = array(
 'Flag' = array(
 'counterCache' = true,
 )
 );

 I can add flags to invoices no problem (just by creating 
 $invoice['Flag'][...] and then saving the invoice), but I can't figure out 
 how to delete them!

 I've tried:
   $this-FlagInvoice-deleteAll( array( 'invoice_id' = $invoice_id, 
 'flag_id' = $flag_id ) );
 and
   $this-FlagInvoice-deleteAll();

 but I get Call to a member function deleteAll() on a non-object 
 (presumably for the 'FlagInvoice').

 If I add 'FlagInvoice' to the $uses variable at the top of the controller, 
 I get the error that the table doesn't exist in the database.

 I know I'm missing something really obvious here (I'm pretty certain I've 
 even done this before!), but I've looked online, and I can't find an 
 answer.  Can anyone help? Thanks!


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from cakePHP version 1.3 to 2.5

2014-05-15 Thread Reuben
Follow the documentation (http://book.cakephp.org/2.0/en/appendices.html), 
and perhaps use dereuromarks upgrade plugin 
(https://github.com/dereuromark/upgrade).

Since you're going through all the releases from 1.3 to 2.5, make sure to 
read the all the guides first, before changing any code.  Just so you know 
to move away from things like Set (use Hash instead), etc.

Also remember to get fresh copies of things like Config/core.php, 
Config/bootstrap.php, webroot/index.php and webroot/test.php, and update 
with any settings from your old release. Because these items are 
application level, rather than core, they often get missed when automatic 
updates get applied.

I would also consider installing CakePHP via composer, in preparation for 
CakePHP 3.0.  Plus is just makes dependency management and upgrades for PHP 
vendor code so much easier.

I just did the 1.3 to 2.4 upgrade (for the second time) a couple of months 
ago.  The automation tools make it really easy, but you'll need to manually 
do stuff like authentication, since it has received a major change between 
releases (but for the better).

Regards
Reuben Helms

On Friday, 16 May 2014 14:21:08 UTC+10, earth wrote:

 I have a project in cakePHP version 1.3 and i want it to upgrade it 
 to cakePHP version 2.5
 Please let me know the best way to do this upgrade.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from cakePHP version 1.3 to 2.5

2014-05-15 Thread Reuben
Oh, and if you're running Git on Windows, you may have to change the case 
of the various directories.

To do this, I had to use a two stage approach:

git mv config config.old
git mv config.old Config

and repeat for all application directories.

On Friday, 16 May 2014 14:21:08 UTC+10, earth wrote:

 I have a project in cakePHP version 1.3 and i want it to upgrade it 
 to cakePHP version 2.5
 Please let me know the best way to do this upgrade.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect all webpages under webroot to login page

2014-05-15 Thread Reuben
Webpages located under app/webroot aren't subject to processing the same 
way that controllers are.

If you have static pages that require authentication, then I would suggest 
usage of the Pages controller 
(http://book.cakephp.org/2.0/en/controllers/pages-controller.html), and 
relocate those static pages under app/Views/Pages. You'll probably also 
need to update the extensions from .htm(l) to .ctp, and make use of the 
Router to allow the .htm(l) extension.

Regards
Reuben Helms

On Thursday, 15 May 2014 18:38:40 UTC+10, Sam wrote:

 I am using cakephp 2.4.5. I would like to redirect all users who have not 
 logged in to a login page. I basically followed the instructions here 
 http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

 In summary, the important part is the following code to AppController.php

 public $components = array('Session',
 'Auth' = array(
 'loginRedirect' = array('controller' = 
 'users', 'action' = 'index'),
 'logoutRedirect' = array('controller' = 
 'users', 'action' = 'login'),
 'authError' = 'You must be logged in to view 
 this page.',
 'loginError' = 'Invalid Username or Password 
 entered, please try again.'
 ));

 Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
 will be re-directed to the login page. However, websites that are located 
 inside webroot with URL that looks like 
 thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to 
 the login page.

 How can I force websites located inside app/webroot folder to be re-directed 
 to the login page?

 Thank you very much.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Redirect all webpages under webroot to login page

2014-05-15 Thread Reuben
I might also suggest change the DocumentRoot of your application to 
app/webroot, since you probably shouldn't be accessing the controllers 
directory directly (unless it was just an example).

On Thursday, 15 May 2014 18:38:40 UTC+10, Sam wrote:

 I am using cakephp 2.4.5. I would like to redirect all users who have not 
 logged in to a login page. I basically followed the instructions here 
 http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

 In summary, the important part is the following code to AppController.php

 public $components = array('Session',
 'Auth' = array(
 'loginRedirect' = array('controller' = 
 'users', 'action' = 'index'),
 'logoutRedirect' = array('controller' = 
 'users', 'action' = 'login'),
 'authError' = 'You must be logged in to view 
 this page.',
 'loginError' = 'Invalid Username or Password 
 entered, please try again.'
 ));

 Any websites with this URL format http://localhost/cakephp245/controllers/XXX 
 will be re-directed to the login page. However, websites that are located 
 inside webroot with URL that looks like 
 thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to 
 the login page.

 How can I force websites located inside app/webroot folder to be re-directed 
 to the login page?

 Thank you very much.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Authake error

2014-05-15 Thread Reuben
What is your Config/routes.php looking like?

It might also be an issue with the plugin, if there was no previous url to 
resolve. You may need to log an issue with the plugin author via Github.

On Thursday, 15 May 2014 03:08:26 UTC+10, Julio Rodriguez wrote:

 Hello, 

 I'm using authake (https://github.com/mtkocak/authake) and getting the 
 following error after successful login:
 Anyone know how to resolve this?

 *Warning* (2): array_merge(): Argument #1 is not an array 
 [*CORE/Cake/Routing/Router.php*, line *1119*]
 Code Context

 array_merge - [internal], line ??
 Router::reverse() - CORE/Cake/Routing/Router.php, line 1119
 AuthakeComponent::getPreviousUrl() - 
 ROOT/plugins/Authake/Controller/Component/AuthakeComponent.php, line 194
 UserController::login() - ROOT/plugins/Authake/Controller/UserController.php, 
 line 437
 ReflectionMethod::invokeArgs() - [internal], line ??
 Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 490
 Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 185
 Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 160
 [main] - APP/webroot/index.php, line 108



 TIA




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Authake error

2014-05-15 Thread Reuben
Actually, looking at the code, getPreviousUrl assumes that the URL stored 
in the session at Authake.previousUrl is either an array or a CakeRequest, 
since that is what is required for Router::reverse().

You'll need to inspect the Session, and see what is being stored in 
Authake.previousUrl. This gets set during the beforeFilter on the component 
(https://github.com/mtkocak/authake/blob/a3bd3ac48f8b6472a048b177a2099ec29821eacb/Controller/Component/AuthakeComponent.php#L160)

On Thursday, 15 May 2014 03:08:26 UTC+10, Julio Rodriguez wrote:

 Hello, 

 I'm using authake (https://github.com/mtkocak/authake) and getting the 
 following error after successful login:
 Anyone know how to resolve this?

 *Warning* (2): array_merge(): Argument #1 is not an array 
 [*CORE/Cake/Routing/Router.php*, line *1119*]
 Code Context

 array_merge - [internal], line ??
 Router::reverse() - CORE/Cake/Routing/Router.php, line 1119
 AuthakeComponent::getPreviousUrl() - 
 ROOT/plugins/Authake/Controller/Component/AuthakeComponent.php, line 194
 UserController::login() - ROOT/plugins/Authake/Controller/UserController.php, 
 line 437
 ReflectionMethod::invokeArgs() - [internal], line ??
 Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 490
 Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 185
 Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 160
 [main] - APP/webroot/index.php, line 108



 TIA




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: CakePHP 2.4.9 authenticated Application

2014-05-15 Thread Reuben
You don't have to use the admin prefix, but it might help if you have two 
types of authenticated users, who might see different versions of an edit 
action on a controller.

For example, in one website I did, we had the administrators who would 
authenticate to edit the site, and we had website members who would 
authenticate to login, and change their profiles, etc.

So we had a Users controller with a admin_edit action for the administrator 
so the admin could edit the users via the admin UI, and an edit action for 
members that wold edit their own profile via the front end UI.

If you only have one type of authenticating user, and want to keep it 
simple, then skip prefix routing.  However, if you think that you might 
have two types of authenticating users (admins and members), then use the 
prefix routing.

Regards
Reuben Helms

On Thursday, 15 May 2014 02:11:49 UTC+10, bobkill01 wrote:

 I look at the possibilities offered by CakePHP for authenticated 
 applications but I do not understand in what cases I should use this or 
 that rule among the three listed below.

 Simple Authentication and Authorization Application
 Simple Acl controlled Application
 Simple Acl controlled Application - part 2

 For example, if I want to create a simple site with an administrator who 
 manages the site and frontend part. I have to use what solution? Can I 
 manage a website with standard methods in the controller (edit, add ...) or 
 I have to use ... admin_edit in core.php  *** ? I am a beginner, thank you 
 for your understanding.

 Thank's


 ***  
 * Set to an array of prefixes you want to use in your application. Use for
  * admin or other prefixed routes.
  *
  * Routing.prefixes = array('admin', 'manager');
  *
  * Enables:
  * `admin_index()` and `/admin/controller/index`
  * `manager_index()` and `/manager/controller/index`
  *
  */
 //Configure::write('Routing.prefixes', array('admin'));



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.