Mutliple validation not working

2016-03-19 Thread Marcus James
Hi,

I am using cakephp version 3, i am trying to add multiple validation but
its not working on password field

$validator = new Validator();
   $validator
->requirePresence('email', 'create')
->notEmpty('email',['message'=>__('Please enter email
address.')])
->add('email', 'email', ['rule' => 'email', 'message'=>__('Please enter
valid email address.')])
->add('email', 'unique', ['rule' => 'validateUnique',
'provider' => 'table','message'=>__('This Email is already taken.')])
->requirePresence('password','create')
->add('password', [
'length' => [
'rule' => ['minLength', 6],
'message' => 'Password need to be at least 6 characters long',
])
   ->notEmpty('password',['message'=>__('Please enter
password.')])
->add('password','length',['rule' => ['minLength',6],'message' =>
__('Password should be minimum 6 character long.')])
->requirePresence('repassword', 'create')
->notEmpty('repassword',['message'=>__('Please enter Confirm Password.')])
->add('repassword','customLength',[
'rule' => function($value, $context) {
if (trim($context['repassword']) !=
trim($context['password'])) {
return false;
}else{
return true;
}
return false;
},
'message' => __('Password and confirm password did not
matched.'),
]);
return $validator;


Thanks,
Marcus

-- 
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup

We will soon be closing this Google Group. But don't worry, we have something 
better coming. Stay tuned for an updated from the CakePHP Team soon.

Like Us on FaceBook https://www.facebook.com/CakePHP
Follow 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.
For more options, visit https://groups.google.com/d/optout.


Increase application process speed

2014-09-26 Thread Marcus James
Hi,

If we have a very large scale application, should we use model association
in model itself or should we bind and unbind model on the fly in
controller. Does it effect the overall speed of the application.

Also does implementing Acl and Auth decreases application speed?

-- 
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: Frontend Javascript framework

2013-12-10 Thread Marcus James
Check out for Ember.js and for SEO see emberjsseo

-- 
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/groups/opt_out.


Re: cronjob in cakephp 1.3

2013-06-21 Thread Marcus James
Hi Chris,

Add this file cron_dispatcher.php under /app/webroot/.

Then to call the function from ssh you need to write it like this:-

/usr/bin/php  path_to_your_project_webroot/cron_dispatcher.php
/guests/update

-- 
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/groups/opt_out.


<>


Re: Many to many relations and Froms

2013-03-11 Thread Marcus James
This article with help you

http://blog.endpoint.com/2009/11/test-fixtures-for-cakephp-has-and.html

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to define a variable in Cakephp

2013-03-05 Thread Marcus James
Instead of *var $view = 'Open';*

Write this

*public $view = 'Open';*

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: search filter in cake 1.3

2013-03-04 Thread Marcus James
Try this

  function search()
  {

$this->User->recursive = 0;
$params = $this->params['url'];

if (!array_key_exists("find", $params)) {

$this->set('users', $this->paginate('User'));
}
else
{
$this->set('users', $this->paginate('User',array('User.firstname
LIKE'=>$params['find'].'%')));
}

  }

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to echo and play videos in Cakephp

2013-02-28 Thread Marcus James
You can use jPlayer http://www.jplayer.org/

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Link to PDF? Yikes!

2013-02-20 Thread Marcus James
Lets say your file is inside /webroot/file/#id/mypdf.pdf

So in your view you write something like this:-

$id = 'value of id from database';

$this->Html->link('see file here','/file/'.$id.'/mypdf.pdf');

Also ,if you are storing the name of the file in your database, you can
replace the name with another variable that holds the name of the file

$fileName = 'vale of name from database';

$this->Html->link('see file here','/file/'.$id.'/'.$fileName);

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Echo a image in cakephp after uploading it

2013-02-14 Thread Marcus James
Html->image('logos/'. $logo['Logo']['filename']); ?>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Echo a image in cakephp after uploading it

2013-02-14 Thread Marcus James
what you wrote above, are you saving 511ca905-f170-49d5-90a0-055083176c8c
value?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Echo a image in cakephp after uploading it

2013-02-14 Thread Marcus James
you should write :-

Html->image('/logos/'. $logo['Logo']['filename']); ?>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Advanced find with mulitple OR/WHERE/AND conditions

2013-01-16 Thread Marcus James
Open the debug mode and see what the exact query is?

-- 
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: CakePHP 1.2 Layout error

2013-01-02 Thread Marcus James
Found the error there was a file BOM encoded

-- 
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.




CakePHP 1.2 Layout error

2013-01-01 Thread Marcus James
Hi,

I made a custom layout for admin panel. The problem is when i validated my
HTML i am getting an error

*"* *Non-space characters found without seeing a doctype first. Expected
.*"

On Firefox the layout renders perfectly when i inspect it but on google
chrome its showing an empty space inside body tag and all the html tag is
going inside body tag.

Any idea what the problem is?

-- 
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: Missing View

2012-11-30 Thread Marcus James
You should create a ctp file index.ctp inside you folder
c:\wamp\www\cakephp\app\view\user\

-- 
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: HABTM Join Table Entries Disappearing

2012-10-11 Thread Marcus James
If you are using $this->CartsOrder->delete(); then it must be deleting the
cartsorder record . You should check for that.




Enjoy,
Marcus

-- 
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: forn create with ID

2012-10-03 Thread Marcus James
Hi Chris

Try this

Form->create('Message', array('action' =>
'compose/'.$user_obj['User']['id'] )); ?>





Enjoy,

Marcus

-- 
Like Us on FacekBook 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: image output tags

2012-09-30 Thread Marcus James
Hi Chris,

Try this :-

Html->link($this->PhotoShow->thumb($user_obj),
'/photos/index/' . $user_obj['User']['username'], array('escape'=>false)) ?>



Enjoy,

Marcus

-- 
Like Us on FacekBook 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: $this->html->link not changing location

2012-09-26 Thread Marcus James
Hi,

Just a small mistake :)

check your line

$this->Html->link($examples['model']['somename'], '/controllername/slug/' +
$examples['model']['slug']);

You wrote '+', it will concat the string. Use '.' sign, so your new code
should be

$this->Html->link($examples['model']['somename'], '/controllername/slug/' .
$examples['model']['slug']);



Enjoy,

Marcus

-- 
Like Us on FacekBook 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: how to implementing sql function like datediff in cake php

2012-09-06 Thread Marcus James
Hi,

Try this example :-

$data =
$this->User->find('first',array('conditions'=>array('User.id'=>1),'fields'=>array('DATEDIFF(now(),User.modified)
as diff','User.*')));




Enjoy,

Marcus

-- 
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-US.




Re: if statement

2012-08-31 Thread Marcus James
Hi,

It means that either the word you are searching is in first position,
that's why  its echoing 0 or (in_array($var_get, $word ) is empty ,meaning
$var_get is not inside the array $word.

-- 
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-US.




Re: PHP functions in controller

2012-08-29 Thread Marcus James
Hi,

You can use any PHP function in your controller just like you use it in
your normal PHP code.

It same in controller too :-

function index()
{
$rand=rand(1,$number);
}


Enjoy ,
Marcus

-- 
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-US.




Re: how to get rid from id column when i use find('list')

2012-06-27 Thread Marcus James
When you write $this->Model->find('list'), it gives you an array in return.
If you want only 1 field value , then you should use
$this->Model->field('filename',array('conition goes here'));

In your case it should be $var =
$this->Login->field('Category',('Login.username'=>$dbuser['Login']['username']));

make sure to check the case of the field name i.e its Category or category
in you database.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: how to get rid from id column when i use find('list')

2012-06-27 Thread Marcus James
Hi,

Try this

$var=
 $this->Login->find('list',

 array(
 'fields'=>array('Category','Category'),
 'order'=>'Login.Category  ASC',
 'conditions'=>array('Login.
username'=>$dbuser['Login']['username'])
 ));



Enjoy,

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Detect a nude image

2012-05-28 Thread Marcus James
Hi All,

I know this is not related to cakePHP but was wondering if there is any
script or code that can help me find if an image is a nude image or not.





Thanks,

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: jQuery append, how to get file content

2012-05-22 Thread Marcus James
In the controller, just add the line to the page function.

function page()
{
 if($this->params['isAjax']==1)
{
$this->layout = '';
}
}


what this does is, it will check if the call is an ajax one or not,if its
an ajax call, we override the layout by stating it as empty.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: jQuery append, how to get file content

2012-05-21 Thread Marcus James
Hi,

In your controllers function you need to add this line

if($this->params['isAjax']==1)
{
$this->layout = '';
}

this checks if the current request call is an ajax one or not.



Enjoy,

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: pass some key in Pagination links

2012-05-09 Thread Marcus James
is your view and the page where you want your link to point are different?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: pass some key in Pagination links

2012-05-09 Thread Marcus James
Hi,

In your views you can use it like this

 echo  $this->Paginator->options(array('url' => $var1.'/'.$var2));

echo $this->Paginator-numbers();

where $var1 and $var2 are the two variable that we want to send.




Enjoy Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


How to show message from default.po into javascript

2012-04-17 Thread Marcus James
Hi,

Can any one tell me how to read messages from default.po inside JavaScript.








Thanks,

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problems with Find ('all')

2012-03-28 Thread Marcus James
Hi,

I think your condition clause is not properly written.

Try this

$dados = $this->Usuario->find('all', array('conditions'=>array(
   'OR'=>array(array('nome_usuario
LIKE'=>'%'.$this->data['valor'].'%',
'ocupacao_usuario'=>$this->data['valor']),array('religiao_usuario'=>$this->data['valor']),array('email_usuario'=>$this->data['valor']);




Enjoy,

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Data retrieval

2012-03-13 Thread Marcus James
Hi Alex,

Just use if condition like this


 









Enjoy,
Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: sending json / jquery data manually from controller to view

2012-02-10 Thread Marcus James
Is your debug mode set to 0 ? Try with setting it to 0 .

Regarding the errors , it would be nice if you post what errors you are
getting

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Team members invitation

2011-11-18 Thread Marcus James
Hi ,

I have 2 year of exp in cake php and would like to join your team


Thanks

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


CakePHP and YQL (Yahoo Query Language)

2011-11-12 Thread Marcus Clarke
Can the two work together and you provide examples of incorporate YQL
within CakePHP project?

thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Strange Problem with default.po

2011-10-16 Thread Marcus James
Hi All,

I have a strange problem with default.po file, i am creating a
multi-lingual website, the problem is the when i see the file in windows any
browser the site works fine

and all text are loaded from default.po but when i access the website from a
macbook it doesnot show the text from default.po

Can any one tell me how to fix it, i have downloaded stable 1.3.8 version


Thanks

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: element vs controller vs component vs helper Best Practice suggestions

2011-10-15 Thread Marcus James
Hi Tom,

Making an element will speed up your application, you can easily call the
function in the element by using

requestAction('your_controller/your_function');

foreach($data as $record){


your html code goes here

}?>


in your function instead of setting data you just need to return it.

like

function myfunction()
{
$users = $this->User->findAll();

return $uses;
}


By doing this your application will be fast

Enjoy

Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Limiting the output from DB

2011-10-15 Thread Marcus James
Hi Garret,

 2 things:-


   1. *In your controller use this

$this->set('provider', $this->paginate('Provider'));

   *
   2. *In your view add this line at the end

   echo <http://www.php.net/echo> $this->Paginator->numbers()*

*
*
*Enjoy*
*
*
*Marcus*

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: how can I validate this field?

2011-10-15 Thread Marcus James
Hi heohni


Well for your first problem, the email one, add allowEmpty validation in
that, for your password validation i am sure you are encrypting
your password , what i suggest is you must first validate all the form field
and if successful then encrypt your password field before saving.


Enjoy Marcus

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Naming Conventions

2011-05-27 Thread Marcus Silva
Thanks brother...

On May 27, 10:51 am, Kunal P  wrote:
> packages_prices wont work, because Cake will consider it as many to many
> link table, & will look for packages & prices tables differently.
>
> So you need to use *package_prices *
> *
> *
> TIPs : If you are not sure how cake would behave with conventions then just
> do BAKE ALL tool.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Pagination Limits

2011-05-27 Thread Marcus Silva
This is how you can do it:

$this->paginate['Account']['limit'] = 3;
$this->paginate['Account']['order'] = 'RAND()';
$this->paginate['Account']['conditions'] = array();
$this->set('accounts',$this->paginate('Account'));

Replace Account with the model name.  Thats how you do it in the
controller.  If you want you can skip doing this all the time by
simply declaring $paginate in the app controller.  In there you can
list as many paginating default data you want.

I hope its been helpful.

cheers

On May 26, 2:11 pm, Okalany Daniel  wrote:
> Hi All,
> i can't seem to be able to limit the number of records returned from cakephp
> pagination.
>
> $this->paginate('limit'=>30);
> limits the number of results per page. But i want to limit the total dataset
> returned. Set it to like 300 since i have a very large table.
>
> regards,
> Daniel

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Naming Conventions

2011-05-27 Thread Marcus Silva
Hey folks,


Coding an application and got stuck with some naming conventions
issue.

The app that I am building will have one Package, packages has many
prices.  I am not entirely sure how the tables should be name.

Should they be named:  packages (model = Package) and the packages
price table be named: packages_prices (model = PackagesPrice) or
package_prices (model = PackagePrice)?

What do you guys think would be the best way to-do this?

Many many thanks in advance...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Saving data in Behavior

2009-12-14 Thread Marcus Silva
Hello folks,

Just writing a model Behavior and got stuck onto something


Is there a way to save multiple records using the beforeSave method in
the Behavior???

I got the following code, but for some reason it fails or the data is
erased etc...

foreach($files as $i => $file){
$dest = $file['destination'];

if($this->uploadFile($file['tmp_name'],$this->setPath($model,
$dest))){
$src = $this->setPath($model,$dest);
$thumb->renderThumb(array('src'=>$src));
//$thumb->renderThumb(array('src'=> 
$src,'w'=>'600','h' =>
'600'));

$model->data[$model->alias][$fileField] = $dest;
$listed[] = $dest;
if($this->__settings[$model->alias]['list'] == 
false){
$conditions_data = 
$model->data[$model->alias];
$fields = array_keys($conditions_data);
if(isset($conditions_data['created']))

unset($conditions_data['created']);
if(isset($conditions_data['modified']))

unset($conditions_data['modified']);

$conditions = array();
//foreach($conditions_data as $key => 
$value)

//$conditions[$model->alias. '.'. $key] = $value;

//unset($conditions_data[$key]);

$conditions[$model->alias. '.'. 
$fileField] = $dest;
$params = array('conditions'=> 
$conditions);
//if($model->find('count',$params)) 
unset($files[$i]); continue;
//$model->create();
//pr($model->data);
$result = 
$model->save($model->data,$validate = false,$fields);
//$model->id;

//$listFields = implode(',',$fields);
//$querySql = "INSERT INTO  
{$model->useTable} ({$listFields})
VALUES ({$listValues});";


if(!$result){
//echo 'Failed saving to 
database, deleting file now...';

unlink($this->setPath($model,$dest));
}
}
}
}

Many thanks in advance for your help!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


New cakephp site - feedback pls!

2009-05-19 Thread Marcus Silva

Hi folks,

Been a while since i last posted in the group, but I have just put one
of my websites online which was developed using cake...

Would you please take a look and let me know what you guys think...
Its only a simple one but any feedback would be greatly appreaciated.

Brazilian Jiu-Jitsu, Mixed Martial Arts -> http://www.msbjj.co.uk

or by the way, if any of you guys live close by, leave the chair and
the keyboard alone for a bit and come along...

Thanks all in advance!
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Record permission handling solution!!!!

2009-03-09 Thread Marcus Silva

I am looking for an easy way to manage user added record to the db.  I
thought that I could use the following idea:

Create a tabled with the following fields: id,record_id,user_id and
record_model.
Basically the idea is to add/delete a entry into that table like so:

id = null
user_id = User currently logged in
record_id = id of linked model record
record_model = Article, Album,Photo,Video etc...

Then whenever the user trie to either edit or delete the record we
find that record and act on it

That way i could just use in the controller or maybe I could write a
behaviour to handle everything:

$conditions = array(
'Record.record_id' => $record_id,
'Record.user_id' => $this->getInfo('User','user_id'),
'Record.record_model' => $this->{$this->modelClass}->name,
);


if($record = $this->Record->find('first',array('conditions' =>
$conditions,'fields' => array({
//The user logged in created the record
//The record could be anything really
}


This would only be used to track what records the user can touch in
terms of deleting/editing etc since only the actual user who added the
record would be able to access it...
Admins would overhide this anyway...

Have you guys ever used anything like this and is it actually a good
approach?

Many thanks in advance for anyones input
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Any one looking for a freelance work

2009-01-25 Thread Marcus Silva

I am interested,

Please send me more information  in a private message.

Regards

Marcus Silva


On Jan 25, 8:55 am, Novice Programmer 
wrote:
> Hello,
>
> Please get in touch with me if you are looking for a freelance work. I have
> a site based on cakephp and want to add a few features to it.
>
> --
> Thanks & Regards,
> Novice.
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Mobile billing component

2009-01-11 Thread Marcus Silva

Hello everyone,

I need to write something to collect payment for a website via mobile
phones.

I was just wondering if any of you knew of any good companies and also
if there is a component to do the job already out there.

Any help helps

many thanks in advance

Marcus Silva
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ACL/Auth Speed Issues

2009-01-10 Thread Marcus J. Ertl

AussieFreelancer schrieb:
> Hi there, yes i have put in indexes, im pretty sure i have done it
> right, but it doesn't seem to have made any difference, certainly not
> any significant difference... Is it definitely possible to have a
> working auth system for 10,000+ members?
>   
Indices were not enough for me, so I decided to do some caching, and 
wrote an acl-component with caching.

master =& $controller;
App::import('component', 'Session');
$this->Session = new SessionComponent();
}


function check($aro, $aco, $action = "*") {
$key = str_replace(array('/', '*'),
   array('.', 'all'),
   strtolower('CachedAcl.'.$aco.'.'.$action));
if ($this->Session->check($key)) {
return $this->Session->read($key);
} else {
$result = parent::check($aro, $aco, $action);
$this->Session->write($key, $result);
return $result;
}
}
}

?>

Bye
Marcus

--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cakephp interactive home page tutorial...

2008-12-18 Thread Marcus Silva

Hi Kyle,

That's exactly what I was looking for.  thank you

Kyle Decot wrote:
> I think what your referring to is know is the "Coda Slider Effect".
> There's a really good tutorial of how to do this at:
>
> http://jqueryfordesigners.com/coda-slider-effect/
>
>
> Marcus Silva wrote:
> > Hi folks,
> >
> > while many of you may find this question completely irrelevant, i
> > still would like to ask it and any help would be kindly appreciated.
> >
> > Does anyone know a good tutorial that I could use to create something
> > similar to the Cakephp home page sliding content effects?
> >
> > I do know that Cake uses the jquery interface elements found here :
> > http://interface.eyecon.ro/ , but I could not find anything there that
> > I could use.
> >
> > Been searching on Google for ages and still havent found anything that
> > I could follow and try to build on.
> >
> > Hope some of you may be able to help.
> >
> > many thanks in advance...
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Cakephp interactive home page tutorial...

2008-12-18 Thread Marcus Silva

Hi folks,

while many of you may find this question completely irrelevant, i
still would like to ask it and any help would be kindly appreciated.

Does anyone know a good tutorial that I could use to create something
similar to the Cakephp home page sliding content effects?

I do know that Cake uses the jquery interface elements found here :
http://interface.eyecon.ro/ , but I could not find anything there that
I could use.

Been searching on Google for ages and still havent found anything that
I could follow and try to build on.

Hope some of you may be able to help.

many thanks in advance...
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Getting simpletest to work with test DB

2008-12-12 Thread Marcus

On Dec 11, 10:55 pm, mark_story  wrote:
> Should be fixed now! :)

Indeed, it works again :)

Thank you, Mark.

Marcus
--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Tip: ignoring tmp dirs in Subversion

2008-12-11 Thread Marcus

On Dec 11, 6:40 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote:
> This always confused me.
>
> cd app
> svn up
> find tmp -type d | grep -v svn| xargs -L1 svn propset svn:ignore '*'
> svn commit -m "ignoring app/tmp in subversion"

This isn't a good solution: If you check out your project on another
machine, the whole 'tmp' directory and its structure is missing.

Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Getting simpletest to work with test DB

2008-12-11 Thread Marcus

On Dec 11, 5:01 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote:
> > Same problem here. The error message "Database table not found"
> > appeared with changeset 7870 of CakePHP.
>
> So an earlier changeset might work for me?

Maybe. Here it works when I downgrade CakePHP to revision 7869.

Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Getting simpletest to work with test DB

2008-12-11 Thread Marcus

On Dec 11, 3:22 pm, mark_story <[EMAIL PROTECTED]> wrote:
> How are your fixtures setup?
> Are you using imports?
> Are you initializing your models in setup() or startTest()?
> Are you using ClassRegistry::init() or are you use new Model()?

Hey Mark,

(i) Fixtures Setup (comments and wihitespaces stripped out)

user_group_fixture.php:

class UserGroupFixture extends CakeTestFixture
{
  public $name = 'UserGroup';
  public $import = array('model' => 'UserGroup', 'records' => true);
}

user_fixture.php:

class UserFixture extends CakeTestFixture
{
  public $name = 'User';
  public $import = array('model' => 'User', 'records' => false);
  public $records = array(
array(
  'id'=> 1,
  'user_group_id' => 2,
  'name'  => 'foo',
  'password'  =>
'288f5ed10f9b731149ad3e3bcdd6add568bb61a3',
  'salt'  => '34da1b0c',
  (...)
)
  );
}

(ii) Using imports

Yes, schema is imported in all cases, records just in some cases.

(iii) Initializing of models

The model is initialized with ClassRegistry::init():

user.test.php

class UserTestCase extends CakeTestCase
{
  public $User = null;
  public $fixtures = array('app.user', 'app.user_group');
  public function start()
  {
parent::start();
Configure::write('debug', 2);
  }

  public function end()
  {
  parent::end();
  }

  public function startTest($method)
  {
$this->User = ClassRegistry::init('User');
$this->User->query("-- >>>>>>>>>>>>>>>>>>>>>> STARTING TEST: " .
$method . " <<<<<<<<<<<<<<<<<<<<<<<<");
  }

  public function endTest($method)
  {
  }

  public function testHashPassword()
  {
$this->assertEqual($this->User->hashPassword('foo'), 'bar');
  }
}

In this example, the user model is associated with the user_group
model (user belongsTo user_group, user_group hasMany user). Tests are
failing with "Error:  Database table user_groups for model UserGroup
was not found." in this case.

This setup was fine until revision 7869. As of revision 7870 tests are
failing.

Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Getting an array of errors during validation

2008-12-11 Thread Marcus

On Dec 11, 9:14 am, gearvOsh <[EMAIL PROTECTED]> wrote:
> So I understand the Model validation using $validate. I applied snooks
> multiple validations 
> usinghttp://snook.ca/archives/cakephp/multiple_validation_sets_cakephp/,
> all that works perfectly.
>
> I do however dislike it when a field errors, the error message is
> shown after the input. Id rather a list of all errors be shown above
> the form, so what im asking is...
>

Simply use FormHelper::error() to print error messages wherever and
whenever you want:

echo($form->error('Model.field1');
echo($form->error('Model.field2');

(http://api.cakephp.org/class_form_helper.html)

Don't forget to remove the error message from your input fields:

echo($form->input('Model.field1', array('error' => false)));
echo($form->input('Model.field2', array('error' => false)));

Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Getting simpletest to work with test DB

2008-12-11 Thread Marcus

On Dec 10, 8:33 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've got simpletest installed but now I am having problems with the test DB.
>
> I had to change the name of the variable to $test_suite from $test.
> After that I could see the create table statements.
>
> Here is my setup:
>
>         var $test_suite = array(
>                 'driver' => 'mysql',
>                 'persistent' => false,
>                 'host' => 'localhost',
>                 'login' => 'eddie',
>                 'password' => 'eddie',
>                 'database' => 'bph_test',
>                 'prefix' => '',
>         );
>
> But now every test reports
> Error:  Database table forms for model Form was not found. The rest of
> the test aborts.

Same problem here. The error message "Database table not found"
appeared with changeset 7870 of CakePHP.

When calling ClassRegistry::init('Foo') in the startTest method of a
test case, Cake tries to set up 'Foo' with all the associated models
and fails when initializing the first related model: CakePHP reads the
schema definition from database with wrong connection.

When calling ClassRegistry::init('Foo'), Cake uses the 'default'
connection for getting the schema for 'Foo' and everything works fine.
Then the first related Model is initialized, CakePHP tries to read the
schema, but now with the 'test_suite' connection, which raises the
error because the table doesn't exist in the test database.

Is this an error that should be filed to trac?

Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: jQuery helper....

2008-12-08 Thread Marcus Silva

Hey Gonzalo,

Thanks for the help.

On Dec 8, 1:10 pm, "Gonzalo Servat" <[EMAIL PROTECTED]> wrote:
> On Mon, Dec 8, 2008 at 10:47 AM, Marcus Silva <[EMAIL PROTECTED]>wrote:
>
>
>
> > Does anyone know if anyone has written a jQuery helper?
>
> > Really need one to add similar features found here:
> >http://ui.jquery.com/demos
> > to a site.
>
> > Any hints/help will be greatly appreciated.
>
> > Many thanks in advance.
>
> As per the talk Felix gave at the CakeFest which just finished last week, I
> believe he mentioned that a helper is on its way to do basic tasks, but to
> do more complicated things with jQuery you need to write the JS.
>
> - Gonzalo
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



jQuery helper....

2008-12-08 Thread Marcus Silva

Does anyone know if anyone has written a jQuery helper?

Really need one to add similar features found here: http://ui.jquery.com/demos
to a site.

Any hints/help will be greatly appreciated.

Many thanks in advance.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: cakephp.org down/inaccessable

2008-12-08 Thread Marcus

On Dec 8, 12:04 pm, Milmar <[EMAIL PROTECTED]> wrote:
> It should be possible. The PHP api itself has a downloadable chm
> version (maybe it also has downloadable HTML and PDF versions).

You can build the API docs from the CakePHP sources at anytime. Just
take a look at phpDocumentor (http://www.phpdoc.org/).

M.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Problem with HABTM relationship...

2008-11-28 Thread Marcus Silva

Hello,

This is my problem:

I have a user model which is linked to a role model via a HABTM
association.

When a new record is added all the associations are added correctly,
the problem is when I delete a record, the associated records are not
deleted as expected.

Cake also showed the following error:

Warning (512): SQL Error: 1054: Unknown column 'RolesUser.id' in
'field list' [CORE\cake\libs\model\datasources\dbo_source.php, line
521]

So to solve the problem I over wrote the following function from the
core model file located at: app\cake\libs\model\model.php

/**
 * Cascades model deletes to HABTM join keys.
 *
 * @param string $id ID of record that was deleted
 * @return void
 * @access protected
 */
function _deleteLinks($id) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
pr($this->hasAndBelongsToMany);
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$records = $this->{$data['with']}->find('all', array(
'conditions' => array($data['foreignKey'] => 
$id),
'fields' => $this->{$data['with']}->primaryKey,
'recursive' => -1
));
if (!empty($records)) {
foreach ($records as $record) {

$this->{$data['with']}->delete($record[$this->{$data['with']}-
>alias][$this->{$data['with']}->primaryKey]);
}
}
}
}


with this function in app_model.php
/**
 * Cascades model deletes to HABTM join keys.
 *
 * @param string $id ID of record that was deleted
 * @return void
 * @access protected
 */
function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$records = $this->{$data['with']}->find('all', array(
'conditions' => array($data['foreignKey'] => 
$id),
//'fields' => 
$this->{$data['with']}->primaryKey,
'fields' => $data['foreignKey'],
'recursive' => -1
));

if (!empty($records)) {
foreach ($records as $record) {
//added this line;
$this->{$data['with']}->primaryKey = 
$data['foreignKey'];

$this->{$data['with']}->delete($record[$this->{$data['with']}-
>alias][$this->{$data['with']}->primaryKey]);
}
}
}
}

It now works fine, but I am not really if can consider the problem
solved.

Can someone with more experience take a look and let me that it will
not cause any issues.

I did rather not touch the Cake core files...

Many thanks in advance.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP Revision 7896: HABTM Issue (deleting one relation deletes other relations)

2008-11-28 Thread Marcus Silva

Had exactly the same problem :http://groups.google.com/group/cake-php/
browse_thread/thread/64516dd7a1b63d0c/f350fa78c7cfc772?
hl=en&lnk=gst&q=an+easy+way+to+add+roles#f350fa78c7cfc772

nobody has replied to my post. Very sad

It must be a bug for sure, I ended up writting my on function to add
and delete the role of a user.

Hopefully somebody will know what is going wrong.




On Nov 28, 3:51 pm, Milmar <[EMAIL PROTECTED]> wrote:
> This issue might be related to ticket #5579 which was fixed in
> revision 7795. I was seeing the same issue as #5579 for the edit and
> save functions but I verified that it is already fixed in revision
> 7795 and later (I'm currently using revision 7896).
>
> Now, my problem is with the delete function, and it's quite easy to
> reproduce.
>
> For example, you have three tables, namely, "roles", "users", and
> "roles_users" (where "roles_users" is the join table).
>
> After baking, the role model is defined as:
>
>  class Role extends AppModel {
>
> var $name = 'Role';
>
> //The Associations below have been created with all possible keys,
> those that are not needed can be removed
> var $hasAndBelongsToMany = array(
> 'User' => array('className' => 'User',
> 'joinTable' => 'roles_users',
> 'foreignKey' => 'role_id',
> 'associationForeignKey' => 
> 'user_id',
> 'unique' => true,
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'finderQuery' => '',
> 'deleteQuery' => '',
> 'insertQuery' => ''
> )
> );
>
> }
>
> ?>
>
> ...and the user model is defined as:
>
>  class User extends AppModel {
>
> var $name = 'User';
>
> //The Associations below have been created with all possible keys,
> those that are not needed can be removed
> var $hasAndBelongsToMany = array(
> 'Role' => array('className' => 'Role',
> 'joinTable' => 'roles_users',
> 'foreignKey' => 'user_id',
> 'associationForeignKey' => 
> 'role_id',
> 'unique' => true,
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'finderQuery' => '',
> 'deleteQuery' => '',
> 'insertQuery' => ''
> )
> );
>
> }
>
> ?>
>
> The role and user controllers just use a simple scaffold (although the
> issue could still be reproduced even if you're not using a scaffold).
>
> Supposing you have the following data and relations:
> User - User A, User B
> Role - Role A, Role B, Role C
>
> Join table:
> User A <-> Role A
> User A <-> Role B
> User A <-> Role C
> User B <-> Role B
>
> Issue: If you delete User A, ALL relationships (including that of User
> B and Role B) are deleted from the join table. If you delete User B,
> the relationship between User B and Role B will be deleted AND the
> relationship between User A and Role B will ALSO be deleted.
>
> My expected behavior: If you delete User A, only the relationships for
> User A would be deleted from the join table. The relationship for User
> B should remain. If you delete User B, only the relationship for User
> B will be deleted, all relationships for User A should remain.
>
> Is anybody else seeing this issue? (I made a search and didn't see any
> ticket concerning this).
> Or am I just confused and this is actually the correct behavior for
> the delete function?
>
> Thanks.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HABTM pagination

2008-11-27 Thread Marcus Silva

Rafael just answered your question!!!

On Nov 27, 1:59 pm, grigri <[EMAIL PROTECTED]> wrote:
> @Markus and Rafael
>
> What's wrong with just going like this?
>
> $this->set('data', $this->paginate('Model', $conditions));
>
> Works fine for me
>
> hth
> grigri
>
> On Nov 27, 12:41 pm, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > Hi Rafael,
>
> > I think what you really need is to use paginate in the following way
> > in conjunction with custom conditions:
>
> > $conditions = array();  //Add your conditions here
> > $this->paginate['Model']['conditions'] = $conditions;
>
> > //now set the data
>
> > $this->set( 'data', $this->paginate('Model') );
>
> > Maybe that will work, used it before and worked for me...
>
> > Let me know if it worked.
>
> > Cheers
>
> > Marcus
>
> > On Nov 27, 12:32 pm, Rafael Bandeira aka rafaelbandeira3
>
> > <[EMAIL PROTECTED]> wrote:
> > > > $this->set('filters',$this->Listing->Cuisine->find('all',array
> > > > ('conditions'=>array('Cuisine.id'=>$searchby))), $this->paginate());
>
> > > what is it supposed to do?
>
> > > I think that what you really want to do is:
>
> > > // in the controller
> > > $this->set('filter', $this->paginate());
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: HABTM pagination

2008-11-27 Thread Marcus Silva

Hi Rafael,

I think what you really need is to use paginate in the following way
in conjunction with custom conditions:

$conditions = array();  //Add your conditions here
$this->paginate['Model']['conditions'] = $conditions;

//now set the data

$this->set( 'data', $this->paginate('Model') );

Maybe that will work, used it before and worked for me...

Let me know if it worked.

Cheers

Marcus




On Nov 27, 12:32 pm, Rafael Bandeira aka rafaelbandeira3
<[EMAIL PROTECTED]> wrote:
> > $this->set('filters',$this->Listing->Cuisine->find('all',array
> > ('conditions'=>array('Cuisine.id'=>$searchby))), $this->paginate());
>
> what is it supposed to do?
>
> I think that what you really want to do is:
>
> // in the controller
> $this->set('filter', $this->paginate());
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



An easy way to add roles to users....

2008-11-27 Thread Marcus Silva

Hi folks,

I am posting this in the hope that some of you may be able to help.

I have a User model which has a HABTM association to Role and vice
versa.

I would like to add role to a user in the following way:


Tables:
users: fields..., HABTM Role
roles: id,name-- HABTM User
roles_users : user_id,role_id (linking table)

Code:
$role = array();
$role['Role'] = array('id' => $role_id);
$role['User']['User'] = array($list_user_id);
$this->User->Role->create();
$this->User->Role->save($role); // the role should really be updated
only and the association added to the user

Failed: Cake has thrown the following error: Warning (512): SQL Error:
1054: Unknown column 'RolesUser.id' in 'field list' [CORE\cake\libs
\model\datasources\dbo_source.php, line 521]

Cannot figure out what the problem really is, do not even know why
cake is looking at that field.

Because that fails I was forced to write a function to add roles to
user, which in my opinion is ugly.

Function:
//Send in the user id and role name
//function declared in user.php model
function addRole($user_id,$role){
$this->expects(array('Role')); //Models are binding when needed only
//$params = array('conditions' => array( 'Role.name' => $role));
$this->Role->recursive = -1;
$role = $this->Role->findByName($role);
$role_id = $role['Role']['id'];
if(!$data = $this->Role->query("SELECT * FROM roles_users AS Role
WHERE role_id = $role_id AND user_id = $user_id")){
//$role['User'] = array('User' => array($user_id));
//$this->Role->save($role); //Not working, errors for some 
reason
//pr('Please save the role now');
$this->Role->query("INSERT INTO roles_users (user_id,role_id) 
VALUES
($user_id,$role_id)");
}
}

That works, but I would like to avoid that if possible.

Do any of you know a smarter way to do the job.

Many thanks in advance...







--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new cakesite...

2008-11-25 Thread Marcus Silva

More suggestion please...

Groups, Forums they all already exist.  There is no point in re-
inventing something that already exists.

more suggestions please ...


On Nov 25, 3:35 pm, stewsnooze <[EMAIL PROTECTED]> wrote:
> I think we should look at Drupal as it's on fire at the moment and
> it's community is very powerful and empowered by the community
> tools.
>
> The Groups.drupal.org site matches people across sectors and interests
> with each other and allows them to discuss Drupal in their particular
> domains.  I would think an equivalent for Cake would bake!
>
> Stew
>
> On Nov 25, 2:22 pm, mark_story <[EMAIL PROTECTED]> wrote:
>
> > Many have tried this and it has not been historically successful.  In
> > the land of forums there is this group, as well as many language
> > specific groups.  There is also already  http://www.cakephpforum.net/
> > and others.  In addition there is the bakery and the cookbook.  The
> > cookbook is more documentation focused but the bakery facilitates
> > articles and case studies and the following discussion quite well.
>
> > I'm not saying its a bad idea, but instead of attempting fragmenting
> > our efforts we should perhaps consolidate them?  Focus our efforts on
> > enhancing and enriching the already existing resources.  And if there
> > is a feature that is sorely missing from one of those resources, we
> > can add it in.
>
> > -Mark
>
> > On Nov 25, 8:19 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > Hi guys,
>
> > > I am planning on building (maybe) a site for us cakephp users.
>
> > > I would like to know weather it would be a good idea to build such a
> > > site and what type of feature you would suggest.
>
> > > The question I ask is this, would you use such a site and what would
> > > like to see in it?
>
> > > Any comment will be great appreciated.
>
> > > Cheers
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new cakesite...

2008-11-25 Thread Marcus Silva

I am thinking something along those lines.

Got some good, concepts already.

More suggestions please...


On Nov 25, 3:53 pm, validkeys <[EMAIL PROTECTED]> wrote:
> Many people learn by example. I have learned quite a lot (not just
> about cake) but about PHP by seeing what other people have done. A
> great resource would be something like a quiz site, where there is a
> new question each day: 1. Program this and people could upload
> their solutions. That could be useful.
>
> On Nov 25, 9:22 am, mark_story <[EMAIL PROTECTED]> wrote:
>
> > Many have tried this and it has not been historically successful.  In
> > the land of forums there is this group, as well as many language
> > specific groups.  There is also already  http://www.cakephpforum.net/
> > and others.  In addition there is the bakery and the cookbook.  The
> > cookbook is more documentation focused but the bakery facilitates
> > articles and case studies and the following discussion quite well.
>
> > I'm not saying its a bad idea, but instead of attempting fragmenting
> > our efforts we should perhaps consolidate them?  Focus our efforts on
> > enhancing and enriching the already existing resources.  And if there
> > is a feature that is sorely missing from one of those resources, we
> > can add it in.
>
> > -Mark
>
> > On Nov 25, 8:19 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > Hi guys,
>
> > > I am planning on building (maybe) a site for us cakephp users.
>
> > > I would like to know weather it would be a good idea to build such a
> > > site and what type of feature you would suggest.
>
> > > The question I ask is this, would you use such a site and what would
> > > like to see in it?
>
> > > Any comment will be great appreciated.
>
> > > Cheers
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: A new cakesite...

2008-11-25 Thread Marcus Silva

A forum would be quite good, but I want something better than a forum.

Any more suggestions bakers

On Nov 25, 1:24 pm, BeroFX <[EMAIL PROTECTED]> wrote:
> A forum, Cake needs a decent forum (www.cakephpforum.netis offline
> 90% of the time),
> a knowledge base with snippets and articles..
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



A new cakesite...

2008-11-25 Thread Marcus Silva

Hi guys,

I am planning on building (maybe) a site for us cakephp users.

I would like to know weather it would be a good idea to build such a
site and what type of feature you would suggest.

The question I ask is this, would you use such a site and what would
like to see in it?

Any comment will be great appreciated.

Cheers
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Manage App's CSS/Scripts

2008-11-18 Thread Marcus Silva

Most of the solutions provide are very ugly and messy as well.

What you really want is to add and remove css/js files as and when you
want and display them when you want too.

To do that you need this:

In the app_controller.php declare a var to hold all the js and scc
files like so:

var $css_files = array('core); // you can add default files to the
array
var $js_files = array('prototype.js'); // you can add default files to
the array

in the beforeRender set the data


function beforeRender(){
$this->set('js_files',$this->js_files);
$this->set('css_files',$this->css_files);
}

Now in any controller you can add css or js files to your page

Example:

A page that has a form

example_controller.php

function add(){
$this->css_files[]  = 'form'; //it can be an array as well
$this->css_files[]  =  array('form','signup','any_css_file'); //it
can be an array as well
$this->js_files[]  =  'fake_script.js'; //it can be an array as well
}

Now in your layout you add  this

//You may can create an element if you like
//echo $this->element('page_files', array('page_files' => array( 'send
in the data to the element' )));

//OR

if(isset($css_files)){
echo $html->css($css_files);  // you may need to put inside a foreach
depending on your version of CakePhp
}

if(isset($js_files)){
if(is_array($js_files)){
foreach($js_files as $js_file){
echo $javascript->link($js_file);
}
}
else{
    echo $javascript->link($js_files);
}
}

Hope it solves your problem

Will write a tutorial on how to do this soon.

Marcus

W:http://www.marsilva.karoo.net/blog/";>Web Development
Programming Blog



On Nov 17, 4:10 pm, teknoid <[EMAIL PROTECTED]> wrote:
> > - Having the ability to add view-specificCSSor Javascript
>
> That's what $scripts_for_layout is for.
> You use it in conjunction, with the false param forCSSand
> Javascript.
> So, for example, from your view:
>
> $html->css('my_css_file', 'stylesheet', array("media"=>"all" ),
> false);
> $javascript->link('my_js_file', false);
>
> will include both files in place of $scripts_for_layout, which should
> be in the  of your layout.
>
> On Nov 17, 9:28 am, i_Am_ToO_SeXy <[EMAIL PROTECTED]> wrote:
>
> > Hello.
>
> > CakePHP is driving me mad.
>
> > I can't figure out a smart way tomanageCSSand Javascript inside my
> >app.
>
> > This is my goal:
> > - Having one (or many)CSSfiles common to all views
> > - Having one (or many) Javascript files common to all views
> > - Having the ability to add view-specificCSSor Javascript
>
> > I tried almost 15 ways without success. I can't understand where's my
> > error(s)
>
> > Sry for bad english.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: acess url only from email

2008-11-12 Thread Marcus Silva

You did not understand it, did you?

The referer will always be your own domain if the hash in the email
validated, since you will be redirecting the user to that page.

Consider this:

A user register for a website and get a confirmation link.  The link
in the email points to:

http://www.yourdomain.com/confimation/email_hash

After the email hash has been validated you send the user to another
page on your site.

In that other page you check if the referer is (yourself)  your own
domain (http://www.yourdomain.com/confimation/email_hash).

Just make sure you do not link to that page from anywhere in your
site.

If you know a better solution then use it and share with others as
well.

Maybe you will get it now.

On Nov 12, 4:40 pm, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
> That still does not prevent a user from sharing the original url in
> the email. Anyone that visits the first page could see the second.
>
> It seems like this is a  moot point if you use authentication or email
> tickets, which would be a much more sound approach.
>
> Any solution you may come up with will not be secure since there is no
> unique way to identify the source as an email. Some web based email
> will show the referrer as the provider (gmail, yahoo) but client based
> applications (thunderbird or outlook) will have a blank referrer.
>
> -EW
>
> On Nov 11, 4:16 pm, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am not sure if I got your question right, but if I did you might be
> > ok doing the following:
>
> > Create an email hash key like Jon Bennett suggested, when the user
> > comes back to your site take
>
> > make the user go to a url on your site where you can check the hashed
> > value, then send the user to another page, in that page check if the
> > referer ($this->refefer()) was the page the user visited originally
> > via the email link, only send the user to this page is the hash key
> > validates.
>
> > That should work
>
> > Hope it helps
>
> > Cheers
>
> > Marcus
>
> > Another way
>
> > On Nov 11, 8:38 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
>
> > > > Yes i thought about this approach. But problem is that i need to make
> > > > access only through email, without restrictions in visit count.
>
> > > In that case don't check for a key's count, jsut allow it. Still use a
> > > key though, ideally random per email sent out, something like:
>
> > > $key = substr(md5($user['User']['name'].$user['User']['email']), 0, 20);
>
> > > Only a really keen individual will bother trying to guess your hash
> > > key, so only valid urls will work.
>
> > > I don't see how you can stop people from passing the urls around
> > > though if they can be used more than once. You can spoof the referrer,
> > > so I really don't know how you could police it effectively.
>
> > > hth
>
> > > jon
>
> > > --
>
> > > jon bennett
> > > w:http://www.jben.net/
> > > iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: acess url only from email

2008-11-11 Thread Marcus Silva

Hi,

I am not sure if I got your question right, but if I did you might be
ok doing the following:

Create an email hash key like Jon Bennett suggested, when the user
comes back to your site take

make the user go to a url on your site where you can check the hashed
value, then send the user to another page, in that page check if the
referer ($this->refefer()) was the page the user visited originally
via the email link, only send the user to this page is the hash key
validates.

That should work

Hope it helps

Cheers

Marcus



Another way

On Nov 11, 8:38 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> > Yes i thought about this approach. But problem is that i need to make
> > access only through email, without restrictions in visit count.
>
> In that case don't check for a key's count, jsut allow it. Still use a
> key though, ideally random per email sent out, something like:
>
> $key = substr(md5($user['User']['name'].$user['User']['email']), 0, 20);
>
> Only a really keen individual will bother trying to guess your hash
> key, so only valid urls will work.
>
> I don't see how you can stop people from passing the urls around
> though if they can be used more than once. You can spoof the referrer,
> so I really don't know how you could police it effectively.
>
> hth
>
> jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Dilemma over choosing right model table structure

2008-11-08 Thread Marcus Silva

I think your solution is very good, but it does not suit my needs as
the system I am building is rather complex.

Instead I am going to use the following solution to store all my
images:

Images table:
id
foreign_id   //user_id
associated_model //User...-- Image->belongsTo = User/Shop/Album/
Profile/More
upload_comment // belongsTo $this->AssociatedModel->name
filename
full_path //stored in files.image.associated_model.filename
has_thumb
thumbs = serialized array  //small / large / medium / xlarge
ext
created
updated

-

Then albums will have the following association:

--Profile
var $hasMany = array(
'Image' => array(
'className' => 'Image',
'foreignKey' => 'foreign_id', //profile_id
'conditions' => array( 'Image.associated_model' => 'Profile'),
)
);

--Shop
var $hasMany = array(
'Image' => array(
'className' => 'Image',
'foreignKey' => 'foreign_id', //shop_id
'conditions' => array( 'Image.associated_model' => 'Shop'),
)
);

--Product
var $hasAndBelongsToMany = array(
'Image' => array(
'className' => 'Image',
'joinTable' => 
'shop_images_products',
'foreignKey'=> 'product_id',
'associationForeignKey' => 'image_foreign_id',
'fields'=> '',
'conditions' => array( 'Image.associated_model' => 
'Shop'),
'unique'=> true,
)
);

Thats the solution I will be using, hope it works.

I might even write a tutorial about this later

Thank you all once again for helping out.


On Nov 8, 8:21 am, Adam Royle <[EMAIL PROTECTED]> wrote:
> Well, not really, you just need one images table for that.
>
> Then in your models you just have an image_id, and set your
> associations up like this:
>
> class Shop extends AppModel {
>
> var $belongsTo = array(
> 'Image' => array('className' => 'Image', 'foreignKey' => 
> 'image_id')
> );
>
> }
>
> class Album extends AppModel {
>
> var $belongsTo = array(
> 'Image' => array('className' => 'Image', 'foreignKey' => 
> 'image_id')
> );
>
> }
>
> If you need more than one image associated, then just use a habtm
> association and create a join table!
>
> I've been using this method for over a year and a half and I've never
> thought about doing it any other way.
>
> Cheers,
> Adam
>
> On Nov 8, 9:29 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > That does help Adam.  Thats exactly the way I will do it now.
>
> > But I think I will end up with many tables which is what really puts
> > me off.  But thats not a problem.
>
> > Should have ShopImage, AlbumImage ProfileImage and so on...
>
> > Many thanks to all for helping out.
>
> > Cheers
>
> > On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > > The way I do this:
>
> > > Tables:
> > > - images
> > > - videos
> > > - documents
>
> > > Each of the tables has the standard fields like mime_type, filesize,
> > > path, etc. And each custom type has any extra fields that may be
> > > necessary (width, height, duration, bitrate, etc).
>
> > > Behaviors:
> > > - FileBehavior
> > > - ImageBehavior extends FileBehavior
> > > - VideoBehavior extends FileBehavior
>
> > > The reason I split into multiple tables is for associations. Often I
> > > want to control what media types are associated with my models. Eg. I
> > > might want a model to have many images but just one video. Plus, this
> > > prevents you from having to constantly check the media type if you're
> > > iterating through one array with multiple media types.
>
> > > Hope that helps.
>
> > > Cheers,
> > > Adam
>
> > > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > > Hi folks,
>
> > > > I am trying to cre

Re: Dilemma over choosing right model table structure

2008-11-07 Thread Marcus Silva

That does help Adam.  Thats exactly the way I will do it now.

But I think I will end up with many tables which is what really puts
me off.  But thats not a problem.

Should have ShopImage, AlbumImage ProfileImage and so on...

Many thanks to all for helping out.

Cheers


On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> The way I do this:
>
> Tables:
> - images
> - videos
> - documents
>
> Each of the tables has the standard fields like mime_type, filesize,
> path, etc. And each custom type has any extra fields that may be
> necessary (width, height, duration, bitrate, etc).
>
> Behaviors:
> - FileBehavior
> - ImageBehavior extends FileBehavior
> - VideoBehavior extends FileBehavior
>
> The reason I split into multiple tables is for associations. Often I
> want to control what media types are associated with my models. Eg. I
> might want a model to have many images but just one video. Plus, this
> prevents you from having to constantly check the media type if you're
> iterating through one array with multiple media types.
>
> Hope that helps.
>
> Cheers,
> Adam
>
> On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > Hi folks,
>
> > I am trying to create system which will let users upload media to the
> > server,  the question that I ask is weather using a single table to
> > store the uploaded files is better than using separate tables to store
> > each file type in terms of coding.
>
> > Seems to me that if I use the multiple table I will be creating
> > exactly the same data, but in a different table.
>
> > Example:  audios,videos,images etc
>
> > My table structure:
>
> > CREATE TABLE `uploaded_files` (
> >   `id` int(11) unsigned NOT NULL auto_increment,
> >   `foreign_id` int(10) unsigned NOT NULL,
> >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> >   `media` varchar(55) NOT NULL,
> >   `filename` varchar(255) default NULL,
> >   `ext` varchar(10) default NULL,
> >   `mime` varchar(55) default NULL,
> >   `filesize` int(11) NOT NULL,
> >   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
> >   `full_path` text NOT NULL COMMENT 'Full path to file_src',
> >   `hasThumb` tinyint(1) unsigned NOT NULL,
> >   `thumbs` text,
> >   `width` int(11) default NULL,
> >   `height` int(11) default NULL,
> >   `description` varchar(155) default NULL,
> >   `created` datetime default NULL,
> >   `updated` datetime default NULL,
> >   PRIMARY KEY  (`id`)
> > ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> > Basically, I am looking for an easy solution that will reduce the
> > amount of code I write
>
> > Hope some of you guys can help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Dilemma over choosing right model table structure

2008-11-07 Thread Marcus Silva

Hi folks,

I am trying to create system which will let users upload media to the
server,  the question that I ask is weather using a single table to
store the uploaded files is better than using separate tables to store
each file type in terms of coding.

Seems to me that if I use the multiple table I will be creating
exactly the same data, but in a different table.

Example:  audios,videos,images etc

My table structure:

CREATE TABLE `uploaded_files` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `foreign_id` int(10) unsigned NOT NULL,
  `model` varchar(255) NOT NULL COMMENT 'Associated model name',
  `media` varchar(55) NOT NULL,
  `filename` varchar(255) default NULL,
  `ext` varchar(10) default NULL,
  `mime` varchar(55) default NULL,
  `filesize` int(11) NOT NULL,
  `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
  `full_path` text NOT NULL COMMENT 'Full path to file_src',
  `hasThumb` tinyint(1) unsigned NOT NULL,
  `thumbs` text,
  `width` int(11) default NULL,
  `height` int(11) default NULL,
  `description` varchar(155) default NULL,
  `created` datetime default NULL,
  `updated` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


Basically, I am looking for an easy solution that will reduce the
amount of code I write

Hope some of you guys can help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Help with validation rule in behaviour

2008-11-05 Thread Marcus Silva

Hi guys,

I am completely stuck and cannot figure out what I am doing wrong.

I have created a custom Upload behaviour but I cannot get the
following validation rule to work.

Just after the setup function in the behaviour I call this function
_create_validation_rule(&$model){} which sets the validation rules,
for my suprise nothing happens.  When I call the function from inside
the beforeValidate function it works, but Cake display the following
error:

Warning (2): preg_match() expects parameter 2 to be string, array
given [CORE\cake\libs\validation.php, line 877]

When I checked the validation.php and pr ( )  the second paramenter it
showed the file array:
Array
(
[filename] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)

)

I must be doing something wrong somewhere, just don't know where and
how to fix it.

Any help would very much appreciated.

Many thanks in advance.


Cheerss
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Displaying dynamic pages as static cached pages

2008-11-04 Thread Marcus Silva

Hello all,

Someone has recently asked about serving dynamic pages as static, so I
decided to write something very quickly solution that those who need
it can use.

Its here ... http://www.marsilva.karoo.net/blog/  bear in mind that I
have not managed to find the time to actually explain what the code
does, you should be able to figure it out yourself.

Hope you like it...

Let me know what you guys think.

Cheers


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Automatic upload behaviour

2008-11-03 Thread Marcus Silva

Hello,

I am trying to create a upload behaviour that does what the system I
am building needs it to do.

I need to know what would be the proper way to do it and what are the
prebuilt functions that the framework uses by order they are called.

Hope someone can help.

Cheers
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Building "Tagging" feature in my site

2008-11-03 Thread Marcus Silva

Hi,

If i did understand what you are trying to achive you could design
your tag relationship in the following way:

Tables

---
Tags
id
name
model
created
updated more if needed etc...


then you would have a linking table which would link tags to its
repective  associated model.

Example:

model_tags //name it as you like
foreign_id   //id of associated model
tag_id



Lets say that my users uses tags etc...

User -- model


var $hasAndbelongsToMany = array(
'Tag' => array(
'className' => 'Tag',
'joinTable' => 'model_tags',
'foreignKey' => 'foreign_id',
'associationForeignKey' => 'tag_id',
'unique' => true,
'conditions'   => array(Tag.model' => 'User'), // Tag.model =>
Associated model class name
'fields' => '',
'order' => '',
'limit' => 5,
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);

In the tag model you could do the same thing.

I know that it works because I used it before ...

Hope it helps you out.

Cheers

On Nov 1, 2:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am trying to build a tagging feature in my site which is a community
> site for a school.
>
> In my site, I have various entity types like : Blog Post, Teacher,
> Book .
>
> Every entry for these entities will have tags associated with it . So,
> atagmay belong to one or more items of different entities.
>
> In a normal core PHP project, I would have designed tables for this in
> the following manner :-
>
> 1) tags : tag_id, tag_name .
> 2) entity_types : entity_type_id, entity_type_name .   [(0, Posts),
> (1, Teachers), (2, Books)]
> 3) posts : post_id, post_name .
> 4) teachers : teacher_id, teacher_name .
> 5) books : book_id, book_name
> 6) entities_tags : tag_id, entity_type_id, entity_id .
>
> So, if a book (entity_type_id = 2) with book_id = 6 has 2 tags
> (tag_id, tag_name) : (11, 'Chemistry') & (23, 'Grade A') , then the
> entry in entities_tags for this will be : (11, 2, 6) & (23, 2, 6) .
>
> I am using CakePHP for my project and I am not able to design the
> tables in CakePHP for this Tagging Feature.
>
> It would be great if people could come up with their suggestions.
>
> Thanks a lot !!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Politics aside.....

2008-10-28 Thread Marcus Silva

Very nice, got stuck on this page though 
http://radar.barackobama.com/news_items/

The links would not work and could not go back to the home page.


On Oct 28, 4:43 pm, Nate <[EMAIL PROTECTED]> wrote:
> Hey, very cool.  You should submit this to the Cookbook's "In the
> Wild" page.
>
> On Oct 28, 11:33 am, Walker Hamilton <[EMAIL PROTECTED]> wrote:
>
> > I just thought I'd let the cakePHP community know that cakePHP is
> > powering a site and a "utility" service at the Barack Obama website. I
> > built both of these.
>
> > Here's the site:http://radar.barackobama.com/
>
> > The utility service isn't anything to look at, but let's just say,
> > it's provided some much needed "plumbing" for our infrastructure.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Building an online shop in CakePhp

2008-10-27 Thread Marcus Silva

Thanks for the tip.

On Oct 26, 7:33 pm, keymaster <[EMAIL PROTECTED]> wrote:
> Have a look at the bakesale project on cakeforge.
>
> Also, just be aware that phpshop is being re-developed oncakephp.
>
> On Oct 26, 2:27 pm, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > Hi guys,
>
> > I hope that some of you may be able to help me with this.
>
> > I am trying to build anonlineshopping application inCakephpto be
> > used as a module for a bigger application.
>
> > I was just wondering if any of you would have any recommendation as to
> > how I could approach this and the sort of tables that I would need in
> > order to buid theshop.
>
> > I can only think of the following tables so far:
> > shops
> > contents
> > products  <- products_images -> images
> > brands
>
> > How about orders - reports - payment options etc...?
>
> > Does anyone have any suggestion?
>
> > Cheers
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Building an online shop in CakePhp

2008-10-26 Thread Marcus Silva

Hi guys,

I hope that some of you may be able to help me with this.

I am trying to build an online shopping application in Cakephp to be
used as a module for a bigger application.

I was just wondering if any of you would have any recommendation as to
how I could approach this and the sort of tables that I would need in
order to buid the shop.

I can only think of the following tables so far:
shops
contents
products  <- products_images -> images
brands

How about orders - reports - payment options etc...?

Does anyone have any suggestion?

Cheers

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: The HABM h bug!

2008-10-20 Thread Marcus Silva

I normally do, just checked it and there is where the problem is.

Thanks a lot.

Cheers




On Oct 20, 11:36 am, "Bernhard J. M. Grün"
<[EMAIL PROTECTED]> wrote:
> Hi!
>
> Just a guess: Do you use afterFind methods in your program? Maybe there is
> the problem? So that afterFind modifies your data in some cases.
>
> -- Bernhard J. M. Grün
>
> 2008/10/20 Marcus Silva <[EMAIL PROTECTED]>
>
>
>
> > Hi everyone,
>
> > I am not really sure weather the following is a bug or not, but it
> > appears to be.
>
> > I my user model I have the follwoing HABM relationship:
> > var $hasAndBelongsToMany = array(
> >'MemberOfClub' => array(
> >'className' => 'Club',
> >'joinTable' => 'club_members',
> >'foreignKey'=> 'club_id',
> >'associationForeignKey' => 'user_id',
> >'fields'=>
> > '',
> >'conditions'=> '',
> >'unique'=> true,
> >)
> >);
>
> > And I have a linking table in the db named club_members which contains
> > the following fields:
> > club_id - PK
> > user_id - PK
> > role_id
>
> > When I query the db like:  $user = $this->User->find(); //Testing
> > I get messed up data like :
>
> > [MemberOfClub] => Array
> >(
> >[0] => Array
> >(
> >[id] => h
> >[created] => h008-10-13
> >[name] => Fake club name
> >[logo] =>
> >[description] => he are something...
> >[template_id] => h
> >[subdomain] => hfake
> >[domain] => hdomain-name
> >[enabled] => h
> >[user_id] => h
> >[ClubMember] => Array
> >(
> >[club_id] => 2
> >[user_id] => 4
> >    [role_id] => 2
> >[role_name] => role_name
> >[created] => 2008-10-19 22:04:36
> >[updated] => 2008-10-19 22:04:36
> >)
>
> >)
>
> >)
>
> > Does anyone know why part of the data is replaced with h and weather
> > it is actually a bug or not.
>
> > I am using the 1.2RC3 version.
>
> > Hope someone can help.
>
> > Cheers
>
> > Marcus
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: PHP Editor

2008-10-20 Thread Marcus Silva

I always use Notepad++, its a great multi language and easy to use
editor.

It can be downloaded at:

http://notepad-plus.sourceforge.net/uk/site.htm

Hope you like it.

Cheers



On Oct 20, 11:22 am, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> What also works and doesn't need installation is notepad2 for 
> Windows:http://www.flos-freeware.ch/notepad2.html
>
> With Linux I like kate.
>
> However now that I am programming nearly fulltime I enjoy the niceties of 
> eclipse. But of course this needs some time to download, install and get used 
> to.
>
> So if you are just beginning with PHP maybe a slimmer editor is better for 
> youre nerves ;-)
>
> Anja
>
> -Ursprüngliche Nachricht-
> Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von 
> Matthieu
> Gesendet: Montag, 20. Oktober 2008 08:46
> An: CakePHP
> Betreff: PHP Editor
>
> Hello, I'd like to know which project editor you would recommend. I'm 
> planning to make a web application using the CakePHP framework.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



The HABM h bug!

2008-10-20 Thread Marcus Silva

Hi everyone,

I am not really sure weather the following is a bug or not, but it
appears to be.

I my user model I have the follwoing HABM relationship:
var $hasAndBelongsToMany = array(
'MemberOfClub' => array(
'className' => 'Club',
'joinTable' => 'club_members',
'foreignKey'=> 'club_id',
'associationForeignKey' => 'user_id',
'fields'=> '',
'conditions'=> '',
'unique'=> true,
)
);

And I have a linking table in the db named club_members which contains
the following fields:
club_id - PK
user_id - PK
role_id

When I query the db like:  $user = $this->User->find(); //Testing
I get messed up data like :

[MemberOfClub] => Array
(
[0] => Array
(
[id] => h
[created] => h008-10-13
[name] => Fake club name
[logo] =>
[description] => he are something...
[template_id] => h
[subdomain] => hfake
[domain] => hdomain-name
[enabled] => h
[user_id] => h
[ClubMember] => Array
(
[club_id] => 2
[user_id] => 4
[role_id] => 2
[role_name] => role_name
[created] => 2008-10-19 22:04:36
[updated] => 2008-10-19 22:04:36
    )

)

)

Does anyone know why part of the data is replaced with h and weather
it is actually a bug or not.

I am using the 1.2RC3 version.

Hope someone can help.

Cheers

Marcus


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP - Warning - Cannot modify header information - headers already sent by

2008-10-16 Thread Marcus Silva

Try removing any hidden character you may have after the php closing
tag (?>).

Example:

  ?>remove anything after the tag

Hope it helps

Cheers

Marcus


On Oct 16, 11:31 am, imu <[EMAIL PROTECTED]> wrote:
> 
>
> controller file is messages_controller.php
>
> 
>  class MessagesController extends AppController{
> var $name = 'Messages';
>
>var $helpers = array (
> 'Html',
> 'Form',
> 'Time'
> );
>
> function index($id = null ){
>   if (!$id) {
>   $this->Session->setFlash('Invalid Topic');
>   $this->redirect(array (
> 'action' => 'index'
>   ), null, true);
> }
> $this->Message->recursive = 1;
>
> $messages = $this->Message->find('all',
> array( 'conditions' => array( 'topic_id' => $id ),'order' =>
> 'Message.id DESC') );
> $this->set('topic_id',$id);
> $this->set('messages',$messages);
> }
>
> function add($id = null) {
> if (!empty ($this->data)) {
> $this->Message->create();
> if ($this->Message->save($this->data)) {
>
> $this->Session->setFlash('The message has been
> added');
> $this->redirect(array (
> 'action' => 'index'
> ), null, true);
>} else {
> $this->Session->setFlash('message posting
> failed. Try again.');
> }
> }
> $users = $this->Message->User->find('list');
> $this->set('topic_id',$id);
> $this->set('users',$users);
>  }
>
> }
> ?>
>
> -
>
> My view file is messages folders in views as add.ctp
>
> -
>
> create('Message',array( 'url' => 'add/'.
> $topic_id ));?>
>
>   New topic
> echo $form->input('message_text');
>  echo $form->input('user_id');
>  echo $form->hidden('topic_id',array( 'value' => $topic_id));
>   ?>
>
> end('post a message');?>
>
>echo $html->link('Go back', array('action'=>'index'));
> ?>
>
> -
>
> When I fill up the add form and submit.
> The data gets inserted into the messages table without any hiccups.
>
> But I get an error during redirection back to the index page like this
>
> 
>
> Warning (2): Cannot modify header information - headers already sent
> by (output started at /opt/lampp/htdocs/cake/message_board/app/
> controllers/messages_controller.php:115) [CORE/cake/libs/controller/
> controller.php, line 587]
>
> Code | Context
>
> $status =   "Location:http://localhost/cake/message_board/messages";
>
> header - [internal], line ??
> Controller::header() - CORE/cake/libs/controller/controller.php, line
> 587
> Controller::redirect() - CORE/cake/libs/controller/controller.php,
> line 568
> MessagesController::add() - APP/controllers/messages_controller.php,
> line 54
> Object::dispatchMethod() - CORE/cake/libs/object.php, line 116
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 259
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 213
> [main] - APP/webroot/index.php, line 90
>
> ---
> The redirection to the index page fails.
>

Re: help with get product by user, function in products controller

2008-10-14 Thread Marcus Silva

Ok,

You might be able to do this:


Add a relationship in your user model; example: User hasMany Product
etc...

Then in you controller you can do the following:


$this->User->id = $id; //Passed in the function

$userProducts = $this->User->Product->find('all',$params =
array(   'conditions' => add any extra condition in here , it can be
an array as well.   ));


//then set the data to be available int he view.

Better yet, you could write a custom function in the User model to get
products for the user, that would save typying etc..

in user.php //model

function getProduct(){
//The model must be associated before trying to do this.

return $this->Product->find();

}

in the controller you do:

$userProducts = $this->User->getProduct();  //SImple

Hope it helps...

Cheers



gabriel wrote:
> Hi, i hope someone can help me here please, I need help with my
> controller function, I want to get products by user_id, unfortunately
> I have no idea where to start, help will be greatfully received.
>
> Here is my code so far...
>
>
> class ProductsController extends AppController {
> var $name = 'Products';
> var $uses = array('Product', 'Category', 'User');
> var $components = array('Search','Files');
>
>   function view() {
>   $this->Product->recursive = 0;
>   $this->set('products', $this->paginate());
>   $this->set('users', $this->User->read(null, $id));
>
>   }
>
> Thanks
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Solution to sharing sessions subdomains!!!

2008-10-14 Thread Marcus Silva

No, not really, but will look into it. how about some example how you
manage your with memcache?

As to the above problem, i really dont't like it as the loggeg in
keeps logged in for a very long time (hours) by default.

hope you can share.

Cheers

On Oct 14, 6:51 am, benko <[EMAIL PROTECTED]> wrote:
> Hi Marcus,
>
> Have you considered using a central database to handle your sessions?
> If doing this causes a performance problem consider storing the
> sessions into a distributed cache like memcached.
>
> This should solve the problem quite easily without having to go and
> make changes to the CakePHP libs.
>
> Hope this helps
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Solution to sharing sessions subdomains!!!

2008-10-13 Thread Marcus Silva

Hello everyone,

I am currently building an application where sessions will be shared
accross the entire network.

I think I found a solution to the problem, but it only works when
security level is set to low in app/config/core.php

Cakephp version 1.2 RC3

In cake/libs/session.php  around line 427 I added the follwoing code:

//Added by me
$domain = $this->host;
//$domain = env("HTTP_HOST");
$parts = explode('.',$domain);
//better be safer than sorry
if(!isset($parts[0])) $parts[0] = 'www';
$subdomain = $parts[0];
$cookie_domain = str_replace($subdomain,'',$domain);
if ($ini_set) {
ini_set('session.cookie_domain', $cookie_domain);
}

It works fine, but I am tryin to achieve the same result with the
security settings set to high.


Does anyone know how I could achieve that?

Is there a better solution for doing this?

Thanks
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Caching ACL in Session

2008-09-11 Thread Marcus J. Ertl

mark_story schrieb:

hi!

Thank you very much for pushing me into the right direction!
> You need to include the Session component in the components array in
> your acl class.  Your session also never gets written as you
>
> return parent::check()
>
> as you return you never get to the other code.
>   
Uhh, that return was from some testing, and I forgot about removing it! :-(

No it works fine for me, the working code is this:

class CachedAclComponent extends DbAcl {
   
function initialize(&$controller) {
$this->master =& $controller;
}
   
function check($aro, $aco, $action = "*") {
$session =& $this->master->Session;
$key = str_replace(array('/', '*'),
   array('.', 'all'),
   strtolower('CachedAcl.'.$aco.'.'.$action));
if ($session->check($key)) {
return $session->read($key);
} else {
$result = parent::check($aro, $aco, $action);
$session->write($key, $result);
return $result;
}
}
}

I had to do some transformations on the key, because it didn't liked the
star and the slash in it! This was the first error, whitch messed all up.

The only thing I don't like about it, is that I have to add

var $components = array('Session');

to the cores acl component.

But it is good enough for me now!

Thank you very much!

Bye
Marcus

PS: Full code under
http://code.google.com/p/cakelinks/source/browse/trunk/controllers/components/cached_acl.php

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Caching ACL in Session

2008-09-11 Thread Marcus J. Ertl
Hi again!

On Thu, Sep 11, 2008 at 12:08 AM, Marcin Domanski <[EMAIL PROTECTED]> wrote:


> If i were you i would think "how can i use sessions in components ?
> hmmm let me think... auth component stores info in session - maybe ill
> look at its source and find out ?"
> not long after i would find mysqlf on one of the greatest resources : The
> API
>

You are right, I did this before my posting! This was one of the many thinks
I did give a try, but they didn't work!

Auth does this:

var $components = array('Session', 'RequestHandler');

to load the Session component. I did this in my code too, but there was no
way to use the Session like this:

$this->Session->read('something');

This just tells me I'm trying to call a method on a non-object!

I'm afraid, the DbAuth-class (and so my CachedAclComponent-class) is not
loaded as component and the var $components is not used at all!

I also tried to load the SessionComponent with something like:

App:import('Component', 'Session');
$this->Session =& new SessionComponent();
$this->Session->initialize($this);
$this->Session->write($key, $value);

This let it work without any errormessage, but the Session stays
unchanged... :-(

Bye
Marcus

-- 
Aber die Augen sind blind. Man musz mit dem Herzen suchen.
Antoine de Saint-Exupery, Der Kleine Prinz

PGP-Fingerprint: 4DD7 5D04 5706 362F 1237 85A8 CBF9 F6ED 0C54 74F2

Das LARP-Portal im Internet: LARP-Welt: http://www.larp-welt.de/
Mein Drachenseitchen: http://www.colorful-sky.de/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Caching ACL in Session

2008-09-10 Thread Marcus J. Ertl

Hi!

I'm just trying to cache the results of acl's check in the session. I
have written a new component, inheriting from DbAcl:

class CachedAclComponent extends DbAcl {
   
function check($aro, $aco, $action = "*") {
return parent::check($aro, $aco, $action);
$key = 'CachedAcl.'.$aro.'.'.$aco.'.'.$action;
if ($this->Session->check($key)) {
return $this->Session->read($key);
} else {
$result = parent::check($aro, $aco, $action);
$this->Session->write($key, $result);
return $result;
}
}
}

and set in conf/core.php:

Configure::write('Acl.classname', 'Cached_Acl');

Acl now uses my check-methode. But there is one thing, that doesn't
work: The session! I can't find any way to write to the session in this
class. I've tried many things, but nothing worked for me! :-(

Bye
Marcus

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



rss as datasource

2008-09-06 Thread Marcus J. Ertl
Hi!

I'm new to cake and doing my first privat project with it
(http://www.larp-welt.de). For this I looked for a way to show rss feeds
from homepages of friends on my homepage.

I browsed the bakery for a solution, but found none I realy liked. So I
wrote my own. In my opinion a behaviore or a component is not the right
way, because there is no difference in a rss-feed and a read only
database for me. OK, the queries are much more simple.

I want to share my solution with you. Please tell me, if it is a good
one, or a bad one!

I came up with a datasource, I'm attaching it to this mail. It uses
lastRSS (http://lastrss.oslab.net/). Of course some code is taken from
the bakery.

No I can setup the rss feeds in conf/database as follows:

var $larpkalender = array(
'datasource'=>'rss',
'url'=>'http://www.larpkalender.de/rssfeed.rdf',
'cacheTime'=>6
);

After setting up a simple model:

class Larpkalender extends AppModel {
var $name = 'Larpkalender';

var $useTable = false;
var $useDbConfig = 'larpkalender';
}

I can now use the rss feed in a controller, and generate views for it,
or using it in a requestAction inside other models views. This is my
controller:

class LarpkalendersController extends AppController {
  
function index() {
$data = $this->Larpkalender->find('all');
return $data['items'];
}
}


I don't know, if this is a clever or a good way, but I like it. In my
opinion the rss feed is a datasource, and I like the easy way to get it
via find() in my controller.

Bye
Marcus

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



rss_source.php
Description: application/php


Re: Linux-Connector - Should it be a model, component, ...?

2008-09-06 Thread Marcus J. Ertl

teknoid schrieb:

Hi!

> So it's
> nearly the same like interacting with a database from my point of
> view.
Why not making it a datasource?

Bye
Marcus

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Cake 1.1.19 stable

2008-09-06 Thread Marcus

I agree, the customer is always right, but you can always refuse to do
the job and explain exactly why.  if you are that a good programmer
you will always have work to do, so why bother.  I bet you the new
cake will be released very soon.  Not so long ago it was only about
40% complete now it is almost 100% and wont be long until it gets
released as stable.

Cheers

Marcus


On Sep 6, 5:43 pm, Dérico Filho <[EMAIL PROTECTED]> wrote:
> Hello Thomas,
>
> I might sound a little bit vexing saying this:
>
> Your customer is right. I am sorry.
>
> Well... 1.2 is yet a Release Candidate, although a very stable and
> robust release candidate, but yet release candidate.
>
> The main reason that it is kept on this name is because there might
> be, yet, some hidden flaws in it. Flaws that neither you nor I know in
> it... That could actually jeopardise your customer's system.
>
> He is not willing to take the risks... I would not be willing to take
> the risks on his shoes as well...
>
> kind regards
> Dérico
>
> [EMAIL PROTECTED] wrote:
> > Hello there,
>
> > I have a client that won't let me use 1.2 because 1.1.19 is tagged as
> > stable whereas 1.2 is RC2...
>
> > I tried and tried to explain to him the many reasons why it would be
> > better and more efficient and more secure etc... to use 1.2 but to no
> > avail since all he can see is the 'stable' tag ...
>
> > So I was wondering if any one had any insight on when the 1.2 version
> > would be tagged as stable.
>
> > I really don't want to go back working with 1.1 :( ...
>
> > I know the work put into this framework and all I'm asking if there is
> > a chance for a stable tagged version within the forthcoming month
> > since this would allow me to advocate 1.2 and save myself some
> > trouble ...
>
> > thanks
>
> > ps. I know I'll probably get answers like : 'it'll be out when it'll
> > be out', or 'just change client' :) but if the release is close I'd
> > hate developing for 1.1.
>
> > ps2. And I surely would like to help for the release but I
> > unfortunately miss time and skills.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Acl permissions almost there - only need some help!

2008-09-02 Thread Marcus

Got the follwoing working with acl component, however I am not really
sure I can grant permissions to users based on the aros and acos
below:

#Aros:
cake acl create aro root guests
cake acl create aro guests members
cake acl create aro members basic
cake acl create aro basic premium
cake acl create aro premium managers
cake acl create aro managers admins


#Acos:
cake acl create aco / Root
cake acl create aco Root Accounts  :: Admins access only
cake acl create aco Root Users
cake acl create aco Root Subscriptions  :: Admins access only
cake acl create aco Root Payments  :: Admins access only
cake acl create aco Root Profiles
cake acl create aco Root Messages
cake acl create aco Root Albums  Premium members only + admins +
managers
cake acl create aco Root Images
cake acl create aco Root Videos  :: Premium members only + admins +
managers
cake acl create aco Root Menus  :: Admins access only
cake acl create aco Root Groups  :: Admins access only
cake acl create aco Root Comments :: Any registered user

I would like to make sure that guest are only allowed content that are
not reserved to basic members
and admins would have controll over all users.

Been trying to work this out for the past two weeks and all I need now
to get the permissions working right.

Can anyone help please.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Acl and Auth

2008-08-30 Thread Marcus

Having the same problem, found that in order to get things working
best bet is using cake built in scaffold as it takes cake of all the
associations.  when everything is working then you can cade stuff
yourself.  Also for ur group model try using the example found here:

http://aranworld.com/article/170/cakephp-acl-and-auth-sample-website
download the sampel site and use the group model.

hope it helps.

cheers

On Aug 29, 11:33 am, luigi7up <[EMAIL PROTECTED]> wrote:
> Auth and acl?
>
> After 4-5 days of trying I finnaly give up :(
>
> I've read and followed about 6-7 tutorials about making user/group
> permissions in Cake and they all have something in common: they
> suck... Don't want offend anyone but it true...
>
> They all have different approach and that's confusing, they all skip
> registration part of user which is silly because that's where
> user.group.id is set and they all take some things for granted.
>
> So, after losing hope I decided to post my code and database tables
> entries to someone who really understands how this component works.
>
> I want to have groups of users: All/Memebers/Admins. newly registered
> users are in Members group by setting group_id=2. I want to restrict
> access to controller/actions for some groups and not users directly.
> As you will see I've put var $actsAs = array('Acl'); in my USER and
> GROUP models to behave like ACL.
>
> **
>
> USERS MODEL:
>
> uses('Sanitize');
> class User extends AppModel {
>
> var $name = 'User';
>
> var $actsAs = array('Acl');
>
> var $belongsTo = array('Group');
>
> function parentNode(){
> if (!$this->id) {
> return null;
> }
>
> $data = $this->read();
>
> if (!$data['User']['group_id']){
> return null;
> } else {
> return array('model' => 'Group', 
> 'foreign_key' => $data['User']
> ['group_id']);
> }
> }
>
> // Ok, even if the ACL behavior takes care of the insertion 
> of the
> // corresponding ARO node, it doesn't save an alias so you 
> have to
> // give one yourself. We'll be using the username for the 
> alias.
> // We'll do this after a new user is saved/inserted, so do it 
> inside
> // the model's afterSave function
> function afterSave($created) {
>
> // Do this if the save operation was an 
> insertion/record creation
> // and not an update operation
> if($created) {
> // Ah, yes... we'll be needing the Sanitize 
> component
> $sanitize = new Sanitize();
>
> // Get the id of the inserted record
> $id = $this->getLastInsertID();
>
> // Instantiate an ARO model that will be used 
> for updating
> // the ARO
> $aro = new Aro();
>
> // I'm using updateAll() instead of 
> saveField()
> // Instead of querying the table to get the 
> id of the
> // ARO node that corresponds to the user, I 
> just provided
> // two field conditions whose combination 
> uniquely identifies
> // the node (Model=> User, Foreign Key=> User 
> id).
>
> // I don't know why it wasn't sanitizing my 
> input and not
> // enclosing the input in quotes. I had to do 
> it myself
> $aro->updateAll(
> 
> array('alias'=>'\''.$sanitize->escape($this->data['User']
> ['username']).'\''),
> array('Aro.model'=>'User', 
> 'Aro.foreign_key'=>$id)
> );
> }
> return true;
> }
>
> }
>
> GROUP MODEL:
>
> uses('Sanitize');
> class Group extends AppModel {
>
> var $name = 'Group';
>
> var $actsAs = array('Acl');
>
> // Associate with the Group table
> var $hasMany = array('User');
>
> function parentNode(){
> if (!$this->id) {
> return null;
> }
>
> $data = $this->read();
>
> if (!$data['Group']['parent_id']){
> return null;
> } else {
> return $data['Group']['parent_id'];
> }
> }
>
> function afterSave($crea

How to grant permissions to users based on content added to the site

2008-08-30 Thread Marcus

Hello all,

I have been using cakephp for about one year now and I am trying to
build a new subscription based application using cake built in auth,
and acl components.

When the user register he/she is added to a group which represents the
aros and each user belongs to a group.

What I want to achieve is the following:

#Aros:
cake acl create aro root guests
cake acl create aro guests members  //members gets permission from
guests
cake acl create aro members bronze /bronze  members gets its
permission from members and so on...
cake acl create aro bronze silver
cake acl create aro silver gold
cake acl create aro gold managers
cake acl create aro managers admins

#Acos:
cake acl create aco / Root
cake acl create aco Root Accounts
cake acl create aco Root Users
cake acl create aco Root Subscriptions
cake acl create aco Root Payments
cake acl create aco Root Messages
cake acl create aco Root Albums
cake acl create aco Root Images
cake acl create aco Root Videos
cake acl create aco Root Menus
cake acl create aco Root Groups
cake acl create aco Root Comments

#Permissions:
cake acl grant admins Root * // not sure if this is right

I want to grant permissions in the following order:

Users in the system can only can view any user profile, but can only
edit their own profile (user has one profile)

Managers can do almost anything, but not touch admins user accounts

Admins on the other hand can do anything on the site.

I got most of the system working, but I am stuck with the permissions.

Also I am tryin to figure out how to makesure that content added to
the site can only be deleted / modified by the user that added it.
Example: A user adds a comment, but only the user which the comment
belongs to can touch it or other than view it etc  Same applies to
other contents on the site such as images albums etc..

Hope any of you can help or if you need any more information in order
to help please ask.

Any help is kind appreciated

Many thanks in advance

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



prefix routing and pagination

2008-08-20 Thread Marcus J. Ertl
Hi!

There are some bugs with prefix routing and pagination. For short: It
doesn't work for other prefix routes then the admin prefix.

I found a patch for this at the bug tracker (#5115), but it didn't
worked for me.

I've played a bit with router php and the patch, and got a version, that
work's most the time for me!

I don't think it is the right way to do it, but I attach the diff to
this mail. It's my first diff, if it doesn't work, please tell me how to
do a better one.

Bye
Marcus

--- router.php
+++ router.php
@@ -779,6 +779,24 @@
 	unset($url[$admin]);
 }
 			}
+			// check for prefixes that are not 'Admin.routing'
+			$prefixes = array();
+			foreach ($_this->routes as $route) {
+if (array_key_exists('prefix', $route[3]))
+{
+	$prefixes[$route[3]['prefix']] = $route[3]['prefix'];
+}
+			}
+			foreach ($prefixes as $cur_prefix)
+			{
+if (!isset($url[$cur_prefix]) && !empty($params[$cur_prefix])) {
+	$url[$cur_prefix] = true;
+$admin = $cur_prefix;
+} elseif (isset($url[$cur_prefix]) && !$url[$cur_prefix]) {
+	unset($url[$cur_prefix]);
+}
+			}
+
 			$plugin = false;
 
 			if (array_key_exists('plugin', $url)) {
@@ -810,7 +828,10 @@
 $url = $originalUrl;
 			}
 			$named = $args = array();
+
+// ME: Prefixes berücksichtigen
 			$skip = array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix', $admin);
+if (is_array($prefixes)) $skip = array_merge($skip, $prefixes);
 
 			$keys = array_values(array_diff(array_keys($url), $skip));
 			$count = count($keys);


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Acl and Auth slow page load

2008-08-20 Thread Marcus J. Ertl
francky06l schrieb:

Hi!
> Index your aco table on alias ...
>   
I have allready done this! The results from the last mail are with this
index!

Bye
Tiggr

Indizes on acos:  Name  Typ KardinalitätFeld
PRIMARY PRIMARY 433 id
alias_index INDEX   36  alias
tree_index  INDEX   433 lft
rght
lft_index   INDEX   433 lft
rght_index  INDEX   433 rght



Indizes on aros: Name   Typ KardinalitätFeld
PRIMARY PRIMARY 30  id
alias_index INDEX   keine   alias
tree_index  INDEX   keine   lft
rght
lft_index   INDEX   keine   lft
rght_index  INDEX   keine   rght



smime.p7s
Description: S/MIME Cryptographic Signature


  1   2   >