Best practice for naming ACOs in Cake?

2013-01-10 Thread LDSign
Hi

Ive implemented a complete ACL-Solution in my app. I am using an 
administration form for acl-management (allow/deny) which I am building 
directly on-the-fly (from the aco-table).

So now, I would like to make this acl-form accessible to some groups with 
non-technical knowledge. Of course displaying the default method aliases 
to the user is not so self-explanatory for everyone. I would like to add a 
real name and a description.

What do you think were I should store this information for the aco? 
Modifying/extend the cake aco-table? Or in a related table? Which is most 
cake-like? In an optimum way the description and the name is related to the 
translateable behaviour to offer different languages.

Has somebody done this already?

Thanks for your input!

Regards,
Frank

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




CakeDC Comments Users plugins together - issues?

2013-01-10 Thread designv...@gmail.com
I am running 2.1 and trying to use the CakeDC Users plugin alongside their 
Comments plugin but am running into an issue...

*Error: * Call to a member function user() on a non-object 
 *File: 
 *C:\wamp\www\xxx\Plugin\Comments\Controller\Component\CommentsComponent.php 
 *Line: * 239


 I can stop the error and make the comments plugin work by adding Auth to 
the main AppController but this then overrides the Users plugin and 
prevents that from working correctly...

Any suggestions? 

TIA!

d.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Issue with removing records (unset) from data array in afterFind

2013-01-10 Thread Kevin
Hi All

I'm experiencing a problem that I can't unset records from the data[] in 
the afterFind callback when the model a related model.
To show my issue clearly I've add this aferFind function to a model (assume 
I'd like to filter all returned records out for some reason):

public function afterFind($results, $primary = false) {
  $results = parent::afterFind($results, $primary);
  unset($results[0]);
  return $results;
}

This works fine for primary models, however not for related models (record 
is not unset).
I've traced it back to this part of the _filterResults function in 
DBOSource.php:

1128foreach ($results as $result) {
1129 $data = $linkedModel-afterFind(array(array($className = 
$result[$className])), false);
1130 if (isset($data[0][$className])) {
1131 $result[$className] = $data[0][$className];
1132 }
1133 }

Line 1130 just ignores the record unset since $data[0][$className] is not 
set - it was just unset!

If I change the code like this, it works for both primary and related:

1128foreach ($results as $key = $result) {
1129 $data = $linkedModel-afterFind(array(array($className = 
$result[$className])), false);
1130 if (isset($data[0][$className])) {
1131 $result[$className] = $data[0][$className];
1132  else {
1134unset($results[$key]);
1135}
1133 }

Am I doing something wrong or is this a cake issue?

Thanks!
Kevin

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




viewing PDF

2013-01-10 Thread Dr. Drijk
I'm using the CakePdf-plugin to parse a view as pdf.

I added to \app\config\bootstrap.php :
 CakePlugin::load('CakePdf', array('bootstrap' = true, 'routes' = true));
 
 Configure::write('CakePdf', array(
'engine' = 'CakePdf.WkHtmlToPdf',
'margin' = array(
'bottom' = 15,
'left' = 50,
'right' = 30,
'top' = 45
),
'orientation' = 'landscape',
'download' = true
));

and to app\config\routes.php: 
Router::parseExtensions('rss', 'json', 'xml', 'pdf');

I added the pdf-folders, and created  view.ctp, and default.cpt

When  I try the view action : /view/1 I get the corresponding view, 
either when i try /view/1.pdf, I don't get a pdf-page but the same html

Where did it go wrong??.






-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: viewing PDF

2013-01-10 Thread euromark
You forgot the RequestHandler component, didnt you?


Am Donnerstag, 10. Januar 2013 17:19:15 UTC+1 schrieb Dr. Drijk:

 I'm using the CakePdf-plugin to parse a view as pdf.

 I added to \app\config\bootstrap.php :
  CakePlugin::load('CakePdf', array('bootstrap' = true, 'routes' = true));
  
  Configure::write('CakePdf', array(
 'engine' = 'CakePdf.WkHtmlToPdf',
 'margin' = array(
 'bottom' = 15,
 'left' = 50,
 'right' = 30,
 'top' = 45
 ),
 'orientation' = 'landscape',
 'download' = true
 ));

 and to app\config\routes.php: 
 Router::parseExtensions('rss', 'json', 'xml', 'pdf');

 I added the pdf-folders, and created  view.ctp, and default.cpt

 When  I try the view action : /view/1 I get the corresponding view, 
 either when i try /view/1.pdf, I don't get a pdf-page but the same html

 Where did it go wrong??.








-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Help with sub domains and dynamic paths

2013-01-10 Thread Neil Berrow
I really hope someone could help.

It's been driving me crazy for 2 days, I've tried so many configurations to 
get my app working.

I moved it from 1 domain to another, and although it renders the 1 page it 
doesn't login or go to sign up like it used to.

I have:
mod_rewrite on
Wildcard installed
Curl is enabled

The database connects and the paths are correct, it renders the homepage 
and login, but after login it doesn't redirect to the users account 
subdomain like it should.

For example, the site homepage http://www.cloudpollen.com/
The login link goes here http://www.cloudpollen.com/login
You login with these details jimmy / steven
It then redirects the homepage

I can only image it might be the .htaccess, but I've tried numerous 
versions but nothing, here's what I've tried:

IfModule mod_rewrite.c
 RewriteEngine on
 RewriteBase/app/
 RewriteRule^$ app/webroot/[L]
 RewriteRule(.*) app/webroot/$1 [L]
 /IfModule

IfModule mod_rewrite.c
 RewriteEngine on
 RewriteRule^$ app/webroot/[L]
 RewriteRule(.*) app/webroot/$1 [L]
 /IfModule

and

IfModule mod_rewrite.c
RewriteEngine on
RewriteBase/app/
RewriteCond %{HTTP_HOST} ^(www\.)?cloudpollen.com$
RewriteRule^$ app/webroot/[L]
RewriteCond %{HTTP_HOST} ^(www\.)?cloudpollen.com$
RewriteRule(.*) app/webroot/$1 [L]
/IfModule

I also tried modifying the above to get some kind of result but all I got 
were 500 errors


Can anyone help?

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




How Can I use different AppController with specific route prefix!?

2013-01-10 Thread Khaled Attia
Hello,

I'm going to create API provider for my application, and I don't want to 
split the API from the main app because there is a lot of tables relations 
in models and components and other stuff that I want to use with the API, 
In same time I don't want to use the main AppController because there is a 
lot of things that happen with each controller (DB queries, load helpers, 
components, redirects, ...etc) that I don't want to use in API.

I tried to create a new directory and at it to App::Build but I faced a 
problem when there is a another controller in main controller directory 
with the same name.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Cake PHP doesn't work on Mac but on Windows

2013-01-10 Thread Theresia Z


I have a big problem with Cakephp. We installed it and built an application 
on windows, everything worked fine. Then I installed Cakephp on two other 
windows-computers and copy-pasted the app-Data, it worked. Now I tried the 
same thing on Mac and it wont work.

The CakePHP installation works, the connection to the database is there and 
on the cakephp-indexsite there are no errors. But as soon as I try to open 
our application, I always get a 404-Error. The Code is exactly the same 
like on my windows-pc and I don't understand why it wont work.

On Windows, we are using XAMPP, on Mac, MAMPP. Might this be a problem?

I hope you can help us with that.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Mongo php process slowness

2013-01-10 Thread Raju Bishnoi
Hi,

I run the below php code with Mongo  MongoClient to insert 100k records.
Mongo took 70-75 second to complete and MongoClient took 440-450 second.

$start = microtime(true);

$objBaseMongoRecord = new BaseMongoRecord();

$objBaseMongoRecord-
setCollectionName(mongotest);

$i = 0;
while ($i  100) {

$data = array(
name = array(
firstname = raju . $i,
lastname = bishnoi . $i),
address = array(
street = raju . $i,
city = city . $i,
state = state . $i,
country = country . $i,
zipcode = 1 . $i),
officephone = 25412541,
homephone = 625412541,
status = A,
date = date('Y-m-d:H-i-s'),
time = time());

$objBaseMongoRecord-ensureIndex(array(time = 1));
$objBaseMongoRecord-insert($data);
$i++;
}

$duration = microtime(true) - $start;
// print in the format 1.2345 for better reading
printf(took %0.4d seconds, $duration);

Can anyone tell me why MongoClient tooks more time and how to make it fast.

Thanks
Raju

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cake PHP doesn't work on Mac but on Windows

2013-01-10 Thread Jonathan Sundquist
What are your error logs telling you?  There could be a number of issues
causing the problem.


On Thu, Jan 10, 2013 at 7:29 AM, Theresia Z zorn@gmail.com wrote:

 I have a big problem with Cakephp. We installed it and built an
 application on windows, everything worked fine. Then I installed Cakephp on
 two other windows-computers and copy-pasted the app-Data, it worked. Now I
 tried the same thing on Mac and it wont work.

 The CakePHP installation works, the connection to the database is there
 and on the cakephp-indexsite there are no errors. But as soon as I try to
 open our application, I always get a 404-Error. The Code is exactly the
 same like on my windows-pc and I don't understand why it wont work.

 On Windows, we are using XAMPP, on Mac, MAMPP. Might this be a problem?

 I hope you can help us with that.

 --
 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 post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.




-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: jquery validation helper not working in 2.2.4

2013-01-10 Thread Matt
Hi,

That's a helper I created a while back and it will work on 2.2.4, although 
you might want to get the latest version from GitHub

https://github.com/vz28bh/CakePHP-JqueryValidationHelper

In that version I recommend opening the form like below, just to make 
things a little cleaner.

?php echo $this-JqueryValidation-createHorizontal('User'); ?

Also, make sure you include Jquery itself 

echo $this-Html-script('jquery.min');

and have defined some validation criteria in your models

'username' = array(
'notempty' = array(
'rule' = array('notempty'),
//'message' = 'Your custom message here',
//'allowEmpty' = false,
//'required' = false,
),
),

If you can get Firefox with Firebug installed you can see if there are any 
Javascript problems.

I assume server side means you only get validation after clicking submit, 
which would be using the Cake model validation instead of Javascript.

Matt

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Extending Plugin Question - location of new controllers/models/views

2013-01-10 Thread mk
 

Hi 

I’m using the cakedc users plugin in my app and have it working well. I’d 
like to extend it now and I have read through the readme “How to extend the 
plugin” https://github.com/CakeDC/users#how-to-extend-the-plugin, where 
they give example controller called AppUsersController and model called 
AppUser.

App::uses('UsersController', 'Users.Controller');

class AppUsersController extends UsersController {

public function beforeFilter() {

parent::beforeFilter();

$this-User = ClassRegistry::init('AppUser');

}

}

App::uses('User', 'Users.Model');
 class AppUser extends User {
   public $useTable = 'users';
 }

My question is where do you place this controller/model/view files? Do you 
extend a plugin and place them the main app folders or the plugin folders?

/myapp/Controller/AppUsersController.php

Or

/myapp/Plugin/users/Controller/AppUsersController.php

I have tried both and it works in the /plugin/ folder but I just want to 
make sure that is correct. 

Thanks in advance 

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Creating objects from the parent object of a hasmany relationship in a controller

2013-01-10 Thread Sam Marland


I am creating a web application that stores user's journeys and I'm build 
this application in CakePHP 2.2.5.

I have a Journey model and that journey model has many coordinate objects 
which store the lat long coordinates.

I want to create a REST API to create journeys that accepts JSON in the 
body which will contain information detailing the journey as well as 
detailing coordinates, to create the coordinates objects that should be 
attached to the journey object all in one controller method. 

I'm not sure where to start.

Here is the code for the add function in the journeys controller

public function add() {
if ($this-request-is('post')) {
$this-Journey-create();
if ($this-Journey-save($this-request-data)) {
$this-Session-setFlash(__('The journey has been saved'));
$this-redirect(array('action' = 'index'));
} else {
$this-Session-setFlash(__('The journey could not be saved. 
Please, try again.'));
}
}
$users = $this-Journey-User-find('list');
$this-set(compact('users'));}

Any help would be appreciated. 

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Authenticating in different controllers

2013-01-10 Thread CCorreia
I have 2 controllers that require authentication, let's say:
 - admins
 - users

Each of this controllers requires a specific table for login information, 
so far I can use the Auth component to login correctly to each controller 
the issue I'm having is that once the user does the login into one of the 
controllers if he navigates to the other it will keep himself logged in 
without requiring the loging information of that controller even though the 
username/password combination it's not the same.

This is currently a migration of a application done in cake 1.3 where this 
was functioning correctly but since I'm new to cake I might be missing some 
step along the way.

This is the code I'm using for one of the controllers, it's the same for 
the other controller just needs to change the userModel value

function beforeFilter(){

$this-Auth-authenticate = array(

AuthComponent::ALL = array(

'userModel' = 'Admin',

'scope' = array(

'Admin.status' = 'active',

)

),

'Form',

'Basic'

);

}

Thanks in advance

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Creating objects from the parent object of a hasmany relationship in a controller

2013-01-10 Thread polutan
Just pass your POST request http://davidwalsh.name/curl-post


2013/1/11 Sam Marland sammarl...@gmail.com

 I am creating a web application that stores user's journeys and I'm build
 this application in CakePHP 2.2.5.

 I have a Journey model and that journey model has many coordinate objects
 which store the lat long coordinates.

 I want to create a REST API to create journeys that accepts JSON in the
 body which will contain information detailing the journey as well as
 detailing coordinates, to create the coordinates objects that should be
 attached to the journey object all in one controller method.

 I'm not sure where to start.

 Here is the code for the add function in the journeys controller

 public function add() {
 if ($this-request-is('post')) {
 $this-Journey-create();
 if ($this-Journey-save($this-request-data)) {
 $this-Session-setFlash(__('The journey has been saved'));
 $this-redirect(array('action' = 'index'));
 } else {
 $this-Session-setFlash(__('The journey could not be saved. 
 Please, try again.'));
 }
 }
 $users = $this-Journey-User-find('list');
 $this-set(compact('users'));}

 Any help would be appreciated.

  --
 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 post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.






-- 
*Coklat Stroberi -- Web Dev Training Centre*
http://www.facebook.com/pages/Coklat-Stroberi/249514251728226  (info lebih
lanjut)
http://coklatstroberi.net
Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau
08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan perumahan
dalung permai.

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Mongo php process slowness

2013-01-10 Thread mulianto
hi 

have you try insert the record in 1 call like batch/bulk insert. i don't know 
if mongo can do this.



Sent from my iPhone

On 10 Jan 2013, at 16:16, Raju Bishnoi rajubishno...@gmail.com wrote:

 Hi,
 
 I run the below php code with Mongo  MongoClient to insert 100k records.
 Mongo took 70-75 second to complete and MongoClient took 440-450 second.
 
 $start = microtime(true);
 
 $objBaseMongoRecord = new BaseMongoRecord();
 
 $objBaseMongoRecord-
 setCollectionName(mongotest);
 
 $i = 0;
 while ($i  100) {
 
 $data = array(
 name = array(
 firstname = raju . $i,
 lastname = bishnoi . $i),
 address = array(
 street = raju . $i,
 city = city . $i,
 state = state . $i,
 country = country . $i,
 zipcode = 1 . $i),
 officephone = 25412541,
 homephone = 625412541,
 status = A,
 date = date('Y-m-d:H-i-s'),
 time = time());
 
 $objBaseMongoRecord-ensureIndex(array(time = 1));
 $objBaseMongoRecord-insert($data);
 $i++;
 }
 
 $duration = microtime(true) - $start;
 // print in the format 1.2345 for better reading
 printf(took %0.4d seconds, $duration);
 
 Can anyone tell me why MongoClient tooks more time and how to make it fast.
 
 Thanks
 Raju
 -- 
 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 post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




ACL in helper

2013-01-10 Thread Jeremy Burns
I have a Navigation plugin that contains a helper. It's used for creating 
menus dynamically. I want to check a user's permissions via ACL before 
adding a menu item. How can I user the ACL component inside the plugin?

-- 
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.