Re: Plugin callbacks and controller hooks

2009-12-18 Thread Jamie
To add to the options already presented:

I wrote a Plugin Callback component that executes callbacks in special
plugin callback classes:

http://jamienay.com/2009/11/an-easy-plugin-callback-component-for-cakephp-1-2/

This works well for the large-scale CMS I built at work. Walther's
solution also looks pretty cool, especially since his is geared
towards custom hooks rather than just hooking on to existing
controller callbacks.

- Jamie


On Dec 18, 4:53 am, Aargh  wrote:
> I would like to know if there is any official (or at least supported /
> under development) mechanism that would allow me to create hooks so
> that i can hook certain plugin functions into a controller.
>
> What would be sweet :
>
> Controller hooks
>
> For example let-s say we have a two statistics plugins. One checks the
> ip, one checks the searchphrase. They both basically work with the
> same data, and could be hooked into the afterFilter or smth.
>
> So the idea would be to be able to register a hook, and then (using
> naming conventions ??), certain (plugin) functions to be called.
>
> View hooks
>
> Would be great such thing to also exist for the views, let-s say we
> register a viewHook called "product_addons", so if we develop a "rate
> the product" plugin, the view would take a ctp from the plugin and
> render the stars and the rating form in that hook. And of course when
> disabling the plugin, searching for the things to be rendered there
> will return empty. Whatever.
>
> I've seen something like (controllerHooks) this at Tarique Sani's
> Cheesecake, in his hitStats plugin. It has some AppInit component that
> will do the hooks. I'm not sure how it works, I've not investgated
> further as the software seems to be quite old (1.1 framework version I
> think). There was another implementation like this called SpliceIt,
> but is not mantained, and seems quite old also.
>
> Is there any reccomended way of actually plugging/unplugging custom
> logic ? Because the plugins seem more like separate apps (that can use
> the main's app logic, and not the other way arround, which is ok after
> all) to me. Maybe I missed something, but I can't find a way to
> elegantly plug in/out custom logic into the controllers.
>
> For plugging in/out custom elements/views i didn't find anything :(.
>
> Probably doing this in models is wrong by design.
>
> Maybe I have some brain damage from other apps I modified. But there
> are plenty of components and helpers that make development a breeze,
> until you need to actually do a plugin that can also easly plug out.
> This is one of the reasons I think apps like wordpress, prestashop and
> similar have a bigger community than any cakephp based app outhere
> (for example CheeseCake is a good photoblog, but without other (spam
> filtering for example) plugins is not to be considered by most
> photographers out there, and noone is willing to create one if there
> is no standard way to develop plugins in cakphp, and everytime you
> have to rediscover how the developer implemented the hooks). I think
> this would make easier for us to port plugins from one app to another,
> thus making creation of feature rich software easier.
>
> Is very hard to do anything but custom software on cakephp, as for
> example creating a good shopping cart will essentially rule out 3'rd
> parties from developing payment or shipping plugins. Most of those
> payment plugins for example do the same thing, but using different
> apis. From the cart's point of view they all act the same, send a
> form, receive an answer, update the cart's status. But there is no
> elegant way to plug in/out these modules. And the funny thing is most
> of them do not even need a table, just a form and a way to validate
> the answer and change cart's status.
>
> Some time ago I developed some publishing software with cake (1.1). It
> was great, until it came to statistics. I had to add lots of
> requestActions in the before and afterFilters. Right now is some kind
> of mess (as removong a "plugin" would also mean to remove the added
> logic into the main apps controllers and views). The next thing I
> develop I would like to not become so messy.
>
> (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
> resize helper spared me a lot of work, 10x god the community is
> strugling to add cool functionality to the framework).
>
> I searched about this topics, but I didn't find much. I checked
> various apps for ideas, but most of them are outdated.
>
> Is there anything like this in plan ? Is there any component that
> already do that ?

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

Re: Applying permissions in fetch time?!

2009-12-18 Thread Vahid Alimohamadi
Last night i thought on this problem and I solved it with this logic:
( SQL Syntax)

[code]
SELECT * FROM posts WHERE id IN(
SELECT foreign_key FROM acos
WHERE id IN(
SELECT aco_id FROM aros_acos WHERE
   aro_id=(SELECT id FROM aros WHERE alias='User:2')
   AND
   aco_id IN (SELECT id FROM acos WHERE model='Post')
   AND
   _read=1
)
)
[/code]

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Walther
I have done something similar for a CMS that I am busy writing.

First look here: http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
That was my inspiration.

Then look here: http://github.com/dakota/CMScout/tree/master/controllers/
That is my event component. Basically, each plugin has a single
plugin_name_events.php file which has all the events in.

On Dec 18, 11:41 pm, Aargh  wrote:
> In the mean time i found this :
>
> http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way
>
> Should be easy following the same idea to make the interesting apps
> controllers "observable", the interested plugin controllers
> "observers", and based on some observers's side config to initialise
> the correct $observers array in every observed controller. Anyway, I'm
> just messing arround, to find a decent solution. SpliceIt looks cool.
> To bad is unmantained.

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


RE: HABTM Additional Field / Checkbox

2009-12-18 Thread Dave
I tried what you said with unbinding then bind as hasMany but all I get is
the skills they selected. I have my $list = find list which returns all the
skills then my data find has the selected skills.
But cant get the selected skills to be pre-checked and cant get the full
list to appear although I can get a full empty list.

I am going with the idea of using the $list as a foreach in the view and
create form checkboxes for each of the list items and add my additional
field that way but just not having any luck. Has anyone added an additional
field to what normally would have been all checkboxes?

Label, Checkbox, Additional field Label, additional field
Label, Checkbox, Additional field Label, additional field
And so on is the goal

Thanks,

Dave

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of John Andersen
Sent: December-16-09 6:49 AM
To: CakePHP
Subject: Re: HABTM Additional Field / Checkbox

As far as I remember, then you have to use not the HABTM relationship when
retrieving the data, but the hasMany relationship to the model for your
HABTM table.

Thus you should make a find that includes (contain) the model for your HABTM
table.

Hope this helps you on the way,
   John

On Dec 16, 3:47 am, "Dave"  wrote:
> I have my HABTM table and was thinking of adding an additional field 
> to the table for "years"  to go with the selectable options.
>
> i have in the form:
>
> input('Skills', array('multiple'=>'checkbox','label' 
> => 'Select your Skills', 'div' => 'options_select'));?>
>
> If I added my years field added to the HABTM how would I get the input 
> field for each of the checkbox items? Any ideas?
>
> Thanks
>
> Dave

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 
cake-php+at http://groups.google.com/group/cake-php?hl=en
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.716 / Virus Database: 270.14.102/2556 - Release Date: 12/15/09
04:22:00

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


Re: Help with Redirect

2009-12-18 Thread kdubya
Oops - I hit Send before I meant to.

Anyway, the line of code you posted:
link('edit', array('action' => 'edit', 'id' =>
$compatible['Compatible']['id'], 'product_id' =>
$product['Product']['id']))?>

What line of HTML does it generate? I think you will find the URL
generated is not what you want. The second argument you are supplying
is an array like this:
array(
  'action'=>'edit',
  'id' =>$compatible['Compatible']['id'],
  'product_id' =>$product['Product']['id']
)


Instead, this should be (IMO):
array(
  'controller'=>'compatibles',
  'action'=>'edit',
  $compatible['Compatible']['id'],
  $product['Product']['id']
)
Notice that there are no  array keys assigned to the to arguments
following the edit action.

And, the definition for the edit() function should be something like:
function edit($compatible_id, $product_id)...

Study the way the function $html->link() is called here:
http://book.cakephp.org/view/206/Inserting-Well-Formatted-elements

Scroll down to see link()

Ken

On Dec 18, 11:28 pm, kdubya  wrote:
> You are going to have to post more of your code before we can help
> more. What is on line 24 of edit.ctp? Show the entire edit() function
> from your compatibles controller.
>
> The line of code you supplied:>link('edit', array('action' 
> => 'edit', 'id' =>
>
> $compatible['Compatible']['id'], 'product_id' =>
> $product['Product']['id']))?>
>
> Ken
>
> On Dec 18, 4:13 pm, Dewayne Pinion  wrote:
>
> > On Fri, Dec 18, 2009 at 12:13 PM, kdubya  wrote:
> > > Try either:
> > > $this->redirect(array('controller' => 'compatibles', 'action' =>
> > > 'index', 'product_id:'.$product_id));
> > > which should result in a URL like:
> > > productsadmin/compatibles/index/product_id:3365
>
> > This would be the right address, but the edit view is not receiving the
> > product_id. I get the error:
>
> > Notice (8): Undefined variable: id [APP/views/compatibles/edit.ctp, line 24]
>
> > Code | Context
>
> > include - APP/views/compatibles/edit.ctp, line 24
> > View::_render() - CORE/cake/libs/view/view.php, line 662
> > View::render() - CORE/cake/libs/view/view.php, line 376
> > Controller::render() - CORE/cake/libs/controller/controller.php, line 773
> > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 248
> > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
> > [main] - APP/webroot/index.php, line 88
>
> > This is the link that sends the info to the edit view:
>
> >             link('edit', array('action' => 'edit', 'id' =>
> > $compatible['Compatible']['id'], 'product_id' =>
> > $product['Product']['id']))?>
>
> > --
> > Dewayne Pinion
> > Web/Software Guy
> > Trenton Technologyhttp://www.trentontechnology.com

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


Re: Help with Redirect

2009-12-18 Thread kdubya
You are going to have to post more of your code before we can help
more. What is on line 24 of edit.ctp? Show the entire edit() function
from your compatibles controller.

The line of code you supplied:
>link('edit', array('action' => 'edit', 'id' =>
$compatible['Compatible']['id'], 'product_id' =>
$product['Product']['id']))?>

Ken

On Dec 18, 4:13 pm, Dewayne Pinion  wrote:
> On Fri, Dec 18, 2009 at 12:13 PM, kdubya  wrote:
> > Try either:
> > $this->redirect(array('controller' => 'compatibles', 'action' =>
> > 'index', 'product_id:'.$product_id));
> > which should result in a URL like:
> > productsadmin/compatibles/index/product_id:3365
>
> This would be the right address, but the edit view is not receiving the
> product_id. I get the error:
>
> Notice (8): Undefined variable: id [APP/views/compatibles/edit.ctp, line 24]
>
> Code | Context
>
> include - APP/views/compatibles/edit.ctp, line 24
> View::_render() - CORE/cake/libs/view/view.php, line 662
> View::render() - CORE/cake/libs/view/view.php, line 376
> Controller::render() - CORE/cake/libs/controller/controller.php, line 773
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 248
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
> [main] - APP/webroot/index.php, line 88
>
> This is the link that sends the info to the edit view:
>
>             link('edit', array('action' => 'edit', 'id' =>
> $compatible['Compatible']['id'], 'product_id' =>
> $product['Product']['id']))?>
>
> --
> Dewayne Pinion
> Web/Software Guy
> Trenton Technologyhttp://www.trentontechnology.com

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


ajax, can't find bug!

2009-12-18 Thread Tom
I can't find bug in this source code? Help!
/Nothing happens when I select a client/
Thanks.

---
/views/elements/activity_filter.ctp
---

Select Activities

create('Activity',  array('type' => 'get', 'action'
=> 'select')); ?>
input('client_id', array('empty' => '--', 'class' =>
'select-refine', 'selected' => isset($this->params['named']
['client_id']) ? $this->params['named']['client_id'] : '')); ?>
input('project_id', array('class' => 'select-
refine', 'selected' => isset($this->params['named']['project_id']) ?
$this->params['named']['project_id'] : '')); ?>


 'getprojects', 'update' =>
'ActivityProjectId'); ?>
observeField('ActivityClientId', $options); ?>
observeField('client_id',array
('url'=>'update_project_select','update'=>'projects'));?>


end('Search'); ?>

-
/views/elements/updata_project_select.ctp
-
 $v) {
echo "$v";
  }
}
?>
---
/views/activities/ajax_dropdown.ctp
---

$v) : ?>



---
activities_controller.php
---

class ActivitiesController extends AppController {

var $name = 'Activities';
var $helpers = array
('Html','Form','Time','Number','Ajax','Javascript');
var $components = array('Auth', 'RequestHandler');
var $paginate = array('limit' => 10,'order' => array('Activity.date
DESC'));

.
.

function getProjects() {
$this->set('options',
$this->Activity->Project->find('list',
array(
'conditions' => array(
'Project.client_id' => 
$this->data['Activity']['client_id']
),
'group' => array('Project.name')
)
)
);
$this->render('/activities/ajax_dropdown');
}

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


Pagination with 2nd order recursive conditions filter

2009-12-18 Thread thomaus
Hi,

I have to do a 2nd order filter por pagination.

My pagination var:

var $paginate = array(
'limit' => 10,
'fields' => array('Campaign.id', 'Campaign.name',
'Campaign.description'),
'order' => array(
'Campaign.id' => 'asc'),
);

My controller function:

$this->Campaign->recursive = 2;
$filter = array('UserCampaign.id = ' => 2);
$campaigns = $this->paginate(null, $filter);
pr($campaigns);

This works great and outputs this:

Array
(
[0] => Array
(
[Campaign] => Array
(
[id] => 2
[name] => Newsletter
[description] => Newsletter campaign
)

[UserCampaign] => Array
(
[id] => 2
[user_id] => 204
[campaign_id] => 2
[User] => Array
(
[id] => 204
[parent_id] => 0
[username] => barça
[fname] => Thomas
)

[Campaign] => Array
(
[0] => Array
(
[id] => 2
[name] => Newsletter
[description] => Newsletter
campaign
[active] =>
[created] =>
[modified] =>
)

)

)

)

)


Now the problem is that I want and I need to write something like
this:

$this->Campaign->recursive = 3;
$filter = array('UserCampaign.User.parent_id = ' => 204);
$campaigns = $this->paginate(null, $filter);
pr($campaigns);

and this outputs:

Warning (512): SQL Error: 1054: Unknown column
'UserCampaign.User.parent_id' in 'where clause'

which is only logical.

But then my question is : what do I have to write to get a pagination
with a condition based on 2nd recursive order???

Thanks in advance.

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


RE: bindModel, unbindModel, updateModel?

2009-12-18 Thread Dave
Im no expert but I have my model function to get recent posts something like
this $this->ModelName->getSomeData($id, $count, $order, ???); 

And in the model function 'count' => $count

So depending on the controller / view I need 5 posts, other grab 10 and just
change the count to what I need.

Dave

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Alan Asher
Sent: December-18-09 6:52 PM
To: cake-php@googlegroups.com
Subject: bindModel, unbindModel, updateModel?

Has anyone run across a function similar to bindModel and unbindModel which
to me would be called updateModel()

 

Basically, I've run across several situations where I just need to update
the model's limit or ordering and finding that I have to use the bindModel
and repeat everything that was in the model before.  

 

I am a big fan of Don't Repeat Yourself, so an updateModel function would be
super handy.

 

I was thinking of just doing something like this
$this->ModelName->belongsTo['OtherModelName']['order']='something new';

 

Any thoughts???

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 
cake-php+at http://groups.google.com/group/cake-php?hl=en


No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.716 / Virus Database: 270.14.102/2556 - Release Date: 12/18/09
04:05:00



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


CakePHP and subdirectories

2009-12-18 Thread Kareem Sabri
Hello,

I'm trying to rebuild my application using CakePHP, but I have a
relatively unique issue (I think). I need to be able to create
numerous subdirectories and have them all inherit the same
functionality as the webroot.

So, for example, I have a class Users. Then I can go to 
http://mydomain.com/users/edit
and use the edit action of my controller. But I also want to be able
to go to http://mydomain.com/subdirectory/users/edit and also use the
edit action. Each subdirectory should inherit the functionality of all
of the controllers in my application, the only difference is each
subdirectory will be associated with a unique Id in certain tables of
my database and will fetch the data it is associated with. Can anyone
suggest a way to accomplish this using CakePHP? URL rewriting perhaps?
I also want to be able to change the views associated with each
subdirectory (or at least set a new default layout), and I need to be
able to create these with relative ease and speed.

I can't do this using GET parameters (ie. mydomain.com/subdirectory/
users/edit?directory_id=6) because clients need to be able to specify
pretty URLs to give out.

Apologies if this is a naive question, I'm not too familiar with using
mod_rewrite. Thanks in advance for any advice!

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


bindModel, unbindModel, updateModel?

2009-12-18 Thread Alan Asher
Has anyone run across a function similar to bindModel and unbindModel which
to me would be called updateModel()

 

Basically, I've run across several situations where I just need to update
the model's limit or ordering and finding that I have to use the bindModel
and repeat everything that was in the model before.  

 

I am a big fan of Don't Repeat Yourself, so an updateModel function would be
super handy.

 

I was thinking of just doing something like this
$this->ModelName->belongsTo['OtherModelName']['order']='something new';

 

Any thoughts???

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
In the mean time i found this :

http://teknoid.wordpress.com/2009/08/10/observer-pattern-the-cakephp-way

Should be easy following the same idea to make the interesting apps
controllers "observable", the interested plugin controllers
"observers", and based on some observers's side config to initialise
the correct $observers array in every observed controller. Anyway, I'm
just messing arround, to find a decent solution. SpliceIt looks cool.
To bad is unmantained.

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


Re: Help with Redirect

2009-12-18 Thread Dewayne Pinion
On Fri, Dec 18, 2009 at 12:13 PM, kdubya  wrote:

> Try either:
> $this->redirect(array('controller' => 'compatibles', 'action' =>
> 'index', 'product_id:'.$product_id));
> which should result in a URL like:
> productsadmin/compatibles/index/product_id:3365
>


This would be the right address, but the edit view is not receiving the
product_id. I get the error:

Notice (8): Undefined variable: id [APP/views/compatibles/edit.ctp, line 24]

Code | Context


include - APP/views/compatibles/edit.ctp, line 24
View::_render() - CORE/cake/libs/view/view.php, line 662
View::render() - CORE/cake/libs/view/view.php, line 376
Controller::render() - CORE/cake/libs/controller/controller.php, line 773
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 248
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
[main] - APP/webroot/index.php, line 88

This is the link that sends the info to the edit view:

link('edit', array('action' => 'edit', 'id' =>
$compatible['Compatible']['id'], 'product_id' =>
$product['Product']['id']))?>


-- 
Dewayne Pinion
Web/Software Guy
Trenton Technology
http://www.trentontechnology.com

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
I already used them. Right now I am starting a new project, which I
would like to opensource, so other developers can write plugins
without messing with the core app. So instead of "to install this
plugin add x lines in the user controller file in before filter
function and y lines in the posts controller file, the plugin to have
some (predefined) hooks. This usually means a event driven approach.
And most of the more featured cake apps out there have aldeady
somewhat implemented this. I'm just looking around for the best
approach to this kind of functionality. Of course this can be done
instantiating a list of the plugins and then execute in the
BeforeFilter() the the functions that start with "BeforeFilter" in a
certain hooks.php file in every plugin directory. Quick and dirty, and
it works. But I am looking for a more elegant solution.


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


Re: Default __() parameters causes problems

2009-12-18 Thread Miles J
Because your not returning from __().



On Dec 18, 9:07 am, djogo  wrote:
> Yes we're getting issues. Specially when we use __ and sprintf
> combined, as in
>
> 
>
> In cake1.2 it renders:
>
> "djogo Username:%s"
>
> Speaking of that, I would like to post a (perl) script I used to
> change _(..)  to __(..). It would be improved, adding (or removing) a
> ",true)" to the end of the call.
>
> 
> #!/usr/bin/perl
>
> open H, $ARGV[0] or die "cant open $ARGV[0]\n";
> open I, ">$ARGV[0].mod";
>
> while()
> {
>         s/^_\s*\(/__\(/g;
>         s/([^_])_\s*\(/\1__\(/g;
>         print I;
>
> }
>
> close I;
> close H;
>
> rename( $ARGV[0], "$ARGV[0].bak" );
> rename( "$ARGV[0].mod", "$ARGV[0]" );
>
> On Dec 18, 2:04 pm, euromark  wrote:
>
> > the switching process will be causing quite a few new bugs i
> > imagine :)
> > at least without really good regexp substitutions
>
> > On 18 Dez., 16:43, djogo  wrote:
>
> > > That's good news indeed.
>
> > > In which version this feature is planned to be in?
>
> > > I guess I'll just use a patched version of cake 1.2.5 until this
> > > version comes out.
>
> > > On Dec 17, 10:45 pm, euromark  wrote:
>
> > > > nice to hear that
> > > > especially as it is used in controllers, components etc too
> > > > and there the echo default is not that much used :)
>
> > > > On 17 Dez., 19:47, "Larry E. Masters aka PhpNut" 
> > > > wrote:
>
> > > > > I have plans to change the __*() functions to return by default it 
> > > > > has not
> > > > > been implemented yet
>
> > > > > --
> > > > > /**
> > > > > * @author Larry E. Masters
> > > > > * @var string $userName
> > > > > * @param string $realName
> > > > > * @returns string aka PhpNut
> > > > > * @access  public
> > > > > */
>
> > > > > On Thu, Dec 17, 2009 at 12:31 PM, euromark 
> > > > > wrote:
>
> > > > > > i do agree that this is one of the few remaining inconsistencies
> > > > > > remaining in cake1.2/1.3
> > > > > > all other functions return by default
> > > > > > e.g. in 1.3 the flash() messages now are returned by default, 
> > > > > > although
> > > > > > scripts/css are inline by default (and therefore echod too).
>
> > > > > > returning should be the default value in most cases
> > > > > > but i dont think in the __() case this is going to happen :)
> > > > > > at least it doesnt look like it
>
> > > > > > using the ___() function might be a very neat way of fixing it for
> > > > > > you, though
> > > > > > the overhead is minimal
>
> > > > > > you should then use the second param though!
> > > > > > function ___($a, $return = true) { return __($a, $return); }
> > > > > > to be more flexible
>
> > > > > > On 17 Dez., 18:39, djogo  wrote:
> > > > > > > Our previous, cake1.1, code was internationalized using php's 
> > > > > > > gettext
> > > > > > > library and the function _().
>
> > > > > > > Cake1.2 now uses __(), which is great, because doesn't require us 
> > > > > > > to
> > > > > > > "compile" .po files anymore.
>
> > > > > > > However, the default behaviour of __() is to echo the translated
> > > > > > > string, instead of returning it, therefore I'm having a lot of 
> > > > > > > heavy
> > > > > > > work going from _( $a )  to __( $a, true ). I have a regexp for
> > > > > > > translating _() to __(), but I couldn't figure out how to insert 
> > > > > > > the
> > > > > > > ",end" parameter in the end of the call.
>
> > > > > > > I though to create a patch in the __() function to change the 
> > > > > > > default
> > > > > > > value, but I don't want to have my own "version" of cakephp.
>
> > > > > > > Or, I may create
>
> > > > > > > function ___($a) { return __($a,true); }
>
> > > > > > > I _really_ think cakephp designers should make the second 
> > > > > > > parameters
> > > > > > > true by default, to turn the transition easy. However, I need my 
> > > > > > > code
> > > > > > > functioning in CAKE 1.2. Do anybody have some tip?
>
> > > > > > Check out the new CakePHP Questions 
> > > > > > sitehttp://cakeqs.organdhelpothers
> > > > > > 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.comFor
> > > > > >  more options, visit this group at
> > > > > >http://groups.google.com/group/cake-php?hl=en

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


Re: Best practise to manage user's selections and user's views

2009-12-18 Thread John Andersen
I use the following ER model in order to register when an item was
viewed, downloaded, etc.

Collection HABTM Item
Collection hasMany CollectionItem
Item HABTM Collection
Item hasMany CollectionItem

So I have the following CakePHP models:
Collection
CollectionItem
Item

The Collection is a classifier, identifying whether an Item was viewed
or downloaded, etc. It is defined as (id, name) and contains the
records:
1, "view"
2, "download"

The Item contains all the - items :)

The CollectionItem is used to register the fact of viewing or
downloading the items. It is defined as (id, collection_id, item_id,
created)

Whenever I want, I can turn on the registration of users or visitors
viewing or downloading an item.

You want to register also the users id, so should add the user_id
column to the CollectionItem.

Hope this helps you on the way :)
   John


On Dec 18, 1:47 pm, "marco.rizze...@gmail.com"
 wrote:
> Hi
> In my application I have the model "Item" and the model "User".
> Every item is visible by some users and it isn't visible by other
> users. So I have a HABTM between "User" and "Item".
> Now I must register when a user views an item and when a user selects
> a item (a user can select some visible items if he wants).
> To do this I have found 2 solutions:
> 1)  Created two models "ItemSelection" and "ItemView" but if I must
> use INNER JOIN (for example If I would the list(with paginate) of
> users that have viewed and selected and certainly item)  I have very
> very bad performance.
> 2)  Add to the users_items table fields "viewed" and "selected" but I
> have a big table with many and many record with null value
>
> I would ask if someone has this problom in the past and how he has
> resolved it.
> Many Thanks
> Bye

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Miles J
I don't see why you just don't use the callbacks?

On Dec 18, 8:04 am, Aargh  wrote:
> Hi,
>
> I know how to use them. The idea was to have something like
>
> MyController {
>
> beforeFilter () {
> defineHook('myHook');
>
> }
> }
>
> And in the plugin to have something like {
>
> PluginController {
> function addCustomLogicToHook(&$controller,$hook,$params){
>
> }
> }
>
> so the requestAction("/bla/bla/addCustomLogicToHook") is filled
> automagically in the hook
>
> Check Tariq Sani's cheesecake, AppInit component and hitStats plugin,
> you'll have a better idea of what I mean. Unfortunately is build on an
> older version of cake, and second, I do not want to steal the code. I
> am just wondering if anyone has a better approach.
>
> http://debuggable.com/posts/welcome-to-the-dark-side-of-plugins-in-ca...
>
> at : Plugin Callbacks / Hooks
>
> The Felix's approach is to :
> callHooks('myHook', null, $this); in the appropriate place, and then
> to create a new file that contain the hookable functions, called
> hooks.php, so that you no longer need to requestAction.
>
> This resembles Tarique's approach but somewhat tariq's approach is
> more intuitive.
>
> this is somewhat required so that more complex event driven
> programming can be done without using tens or hundreds of
> requestAction. while requestAction is ok for a self-centric app, a
> plugin oriented app that lacks hooks (at least in views and
> controllers) is not a choice, especially if you expect 3'd parties to
> cooperate. Is not that I can't manage without them, is that it would
> be sweet to have it as a core feature (like we have Auth for example).
> We can choose to, or not to use it, but would be great to have, so
> that more projects can share code and more complex CMS and such can
> rely on a standard way to hook things in.
>
> Unfortunately, both solutions I found are outdated, and both only have
> controllerHooks.
>
> There is another option to use something like TiramisPHP promises
> (unfortunately nuvole.org is empty), that would be "an implementation
> of the Implicit Invocation Pattern structured around event handling
> for loose coupling and high cohesion in your CakePHP logic;". Not sure
> this actually works.
>
> In the meantime I found this 
> :http://cakealot.com/2009/04/eventful-a-cakephp-event-system/
>
> Seems interesting. Anyone tried It ?
> I am aware that CakePHP is not event driven, but I'm trying to find a
> way to pass over this and have at least some way to hook plugins based
> on "events" in a proper nonhackerish way that in 2 month nobody not
> even the original developer won't know how it actually works.
>
> Or maybe I'm missing something, and there is an obious easier way to
> do this which I do not yet see. Basically right I want to tell the
> beforeFilter of a Posts controller to do a requestAction of a
> plugin ... from the plugin. because if I have 20 plugins (actually
> will be only 5 payment methods) will be a unellegant to disable all
> the "requestAction"s when I want to disable certain plugins. Last time
> as I said I used only cake's core and requestActions, but it feels
> somewhat not right. And I'm sure somebody out there had the same
> problems, would be nice to see their thoughts/approaches to this and
> even nicer to have cake have something like this included in the core
> (like the AUTH component is).

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


Re: Database encryption & security

2009-12-18 Thread WhyNotSmile
I am doing this for a client.  He has access to the database through
his control panel of his web host.  I want it to be encrypted so he
can't read the data.  It's not that I don't want him to see it, but
that there is data which clients might not want him to see.  I also
have access to the database, and they might not want me to see it
either.  So, basically, when you go to PHPadmin, it should be
encrypted.  Does that make sense?

Also, if anyone was to hack into the database somehow, I don't want
them to be able to read the data.

Thanks,
Sharon



On Dec 18, 2:04 pm, robustsolution  wrote:
> of course you are talking about two-way encryption not hashing (one
> way).
>
> by the way what do you mean by the database owner?
>
> either the guy have a full access to the database or a custom access.
>
> if you are the one who has full access, give him a mysql account with
> custom access to all tables except the tables that have sensitive
> info.
>
> otherwise an alternative solution should be required here.

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


Re: Help with Redirect

2009-12-18 Thread kdubya
On Dec 17, 3:30 pm, Dewayne Pinion  wrote:
> Ok, apparently I am braindead, because I am still not grasping the concept
> of a redirect in cake. I have this page:
>
>    productsadmin/compatibles/index/product_id:3365

Where does the above syntax come from (specifically the "product:3365"
part)? Typically, in CakePHP, arguments to an action are passed like
this:
app_name/contoller_name/action_name/argument_1/argument_2

>
> That has an edit link. Clicking on it takes me to this page:
>
>    productsadmin/compatibles/edit/4228

The above is typical of a CakePHP passed argument syntax.

>
> where I can edit the information for a related product.
>
> The update works fine. However, I would like to redirect back to:
>
>    productsadmin/compatibles/index/product_id:3365
>
> I currently have this in my controller:
>
>    $this->redirect(array('controller' => 'compatibles', 'action' => 'index',
> 'product_id' => $product_id));

Your syntax here is incorrect. See the CakePHP manual on redirect
here:
http://book.cakephp.org/view/425/redirect

To pass an argument to the action in a redirect it should look like
this (the third example on the manual page referenced above):
$this->redirect(array('controller'=>'controller_name',
'action'=>'action_name', argument_1));

Try either:
$this->redirect(array('controller' => 'compatibles', 'action' =>
'index', 'product_id:'.$product_id));
which should result in a URL like:
productsadmin/compatibles/index/product_id:3365

OR
$this->redirect(array('controller' => 'compatibles', 'action' =>
'index', $product_id));
which should result in a URL like:
productsadmin/compatibles/index/3365

I hope this helps,
Ken

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


Re: Default __() parameters causes problems

2009-12-18 Thread djogo
Yes we're getting issues. Specially when we use __ and sprintf
combined, as in



In cake1.2 it renders:

"djogo Username:%s"

Speaking of that, I would like to post a (perl) script I used to
change _(..)  to __(..). It would be improved, adding (or removing) a
",true)" to the end of the call.



#!/usr/bin/perl

open H, $ARGV[0] or die "cant open $ARGV[0]\n";
open I, ">$ARGV[0].mod";

while()
{
s/^_\s*\(/__\(/g;
s/([^_])_\s*\(/\1__\(/g;
print I;
}

close I;
close H;

rename( $ARGV[0], "$ARGV[0].bak" );
rename( "$ARGV[0].mod", "$ARGV[0]" );


On Dec 18, 2:04 pm, euromark  wrote:
> the switching process will be causing quite a few new bugs i
> imagine :)
> at least without really good regexp substitutions
>
> On 18 Dez., 16:43, djogo  wrote:
>
> > That's good news indeed.
>
> > In which version this feature is planned to be in?
>
> > I guess I'll just use a patched version of cake 1.2.5 until this
> > version comes out.
>
> > On Dec 17, 10:45 pm, euromark  wrote:
>
> > > nice to hear that
> > > especially as it is used in controllers, components etc too
> > > and there the echo default is not that much used :)
>
> > > On 17 Dez., 19:47, "Larry E. Masters aka PhpNut" 
> > > wrote:
>
> > > > I have plans to change the __*() functions to return by default it has 
> > > > not
> > > > been implemented yet
>
> > > > --
> > > > /**
> > > > * @author Larry E. Masters
> > > > * @var string $userName
> > > > * @param string $realName
> > > > * @returns string aka PhpNut
> > > > * @access  public
> > > > */
>
> > > > On Thu, Dec 17, 2009 at 12:31 PM, euromark 
> > > > wrote:
>
> > > > > i do agree that this is one of the few remaining inconsistencies
> > > > > remaining in cake1.2/1.3
> > > > > all other functions return by default
> > > > > e.g. in 1.3 the flash() messages now are returned by default, although
> > > > > scripts/css are inline by default (and therefore echod too).
>
> > > > > returning should be the default value in most cases
> > > > > but i dont think in the __() case this is going to happen :)
> > > > > at least it doesnt look like it
>
> > > > > using the ___() function might be a very neat way of fixing it for
> > > > > you, though
> > > > > the overhead is minimal
>
> > > > > you should then use the second param though!
> > > > > function ___($a, $return = true) { return __($a, $return); }
> > > > > to be more flexible
>
> > > > > On 17 Dez., 18:39, djogo  wrote:
> > > > > > Our previous, cake1.1, code was internationalized using php's 
> > > > > > gettext
> > > > > > library and the function _().
>
> > > > > > Cake1.2 now uses __(), which is great, because doesn't require us to
> > > > > > "compile" .po files anymore.
>
> > > > > > However, the default behaviour of __() is to echo the translated
> > > > > > string, instead of returning it, therefore I'm having a lot of heavy
> > > > > > work going from _( $a )  to __( $a, true ). I have a regexp for
> > > > > > translating _() to __(), but I couldn't figure out how to insert the
> > > > > > ",end" parameter in the end of the call.
>
> > > > > > I though to create a patch in the __() function to change the 
> > > > > > default
> > > > > > value, but I don't want to have my own "version" of cakephp.
>
> > > > > > Or, I may create
>
> > > > > > function ___($a) { return __($a,true); }
>
> > > > > > I _really_ think cakephp designers should make the second parameters
> > > > > > true by default, to turn the transition easy. However, I need my 
> > > > > > code
> > > > > > functioning in CAKE 1.2. Do anybody have some tip?
>
> > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers
> > > > > 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.comFor
> > > > >  more options, visit this group at
> > > > >http://groups.google.com/group/cake-php?hl=en

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


strange situation

2009-12-18 Thread kicaj
I create very simple Cake search, I use find function, and i get
different result when I use 'www' in url...!?

Check:
http://pcb-polska.pl/szukaj/wzornik (empty)
http://www.pcb-polska.pl/szukaj/wzornik (many results)

Searcher in the right side, You can use many words in polish for
check: dyspersja, zaprawa, grunt, etc.

How do You think, what is problem? Maybe .htaccess?

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
Hi,

I know how to use them. The idea was to have something like

MyController {

beforeFilter () {
defineHook('myHook');
}

}

And in the plugin to have something like {

PluginController {
function addCustomLogicToHook(&$controller,$hook,$params){
}
}

so the requestAction("/bla/bla/addCustomLogicToHook") is filled
automagically in the hook

Check Tariq Sani's cheesecake, AppInit component and hitStats plugin,
you'll have a better idea of what I mean. Unfortunately is build on an
older version of cake, and second, I do not want to steal the code. I
am just wondering if anyone has a better approach.

http://debuggable.com/posts/welcome-to-the-dark-side-of-plugins-in-cakephp:480f4dd5-0eb8-4cab-aeb3-4796cbdd56cb

at : Plugin Callbacks / Hooks

The Felix's approach is to :
callHooks('myHook', null, $this); in the appropriate place, and then
to create a new file that contain the hookable functions, called
hooks.php, so that you no longer need to requestAction.

This resembles Tarique's approach but somewhat tariq's approach is
more intuitive.

this is somewhat required so that more complex event driven
programming can be done without using tens or hundreds of
requestAction. while requestAction is ok for a self-centric app, a
plugin oriented app that lacks hooks (at least in views and
controllers) is not a choice, especially if you expect 3'd parties to
cooperate. Is not that I can't manage without them, is that it would
be sweet to have it as a core feature (like we have Auth for example).
We can choose to, or not to use it, but would be great to have, so
that more projects can share code and more complex CMS and such can
rely on a standard way to hook things in.

Unfortunately, both solutions I found are outdated, and both only have
controllerHooks.

There is another option to use something like TiramisPHP promises
(unfortunately nuvole.org is empty), that would be "an implementation
of the Implicit Invocation Pattern structured around event handling
for loose coupling and high cohesion in your CakePHP logic;". Not sure
this actually works.

In the meantime I found this :
http://cakealot.com/2009/04/eventful-a-cakephp-event-system/

Seems interesting. Anyone tried It ?
I am aware that CakePHP is not event driven, but I'm trying to find a
way to pass over this and have at least some way to hook plugins based
on "events" in a proper nonhackerish way that in 2 month nobody not
even the original developer won't know how it actually works.

Or maybe I'm missing something, and there is an obious easier way to
do this which I do not yet see. Basically right I want to tell the
beforeFilter of a Posts controller to do a requestAction of a
plugin ... from the plugin. because if I have 20 plugins (actually
will be only 5 payment methods) will be a unellegant to disable all
the "requestAction"s when I want to disable certain plugins. Last time
as I said I used only cake's core and requestActions, but it feels
somewhat not right. And I'm sure somebody out there had the same
problems, would be nice to see their thoughts/approaches to this and
even nicer to have cake have something like this included in the core
(like the AUTH component is).



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


Re: Default __() parameters causes problems

2009-12-18 Thread euromark
the switching process will be causing quite a few new bugs i
imagine :)
at least without really good regexp substitutions


On 18 Dez., 16:43, djogo  wrote:
> That's good news indeed.
>
> In which version this feature is planned to be in?
>
> I guess I'll just use a patched version of cake 1.2.5 until this
> version comes out.
>
> On Dec 17, 10:45 pm, euromark  wrote:
>
> > nice to hear that
> > especially as it is used in controllers, components etc too
> > and there the echo default is not that much used :)
>
> > On 17 Dez., 19:47, "Larry E. Masters aka PhpNut" 
> > wrote:
>
> > > I have plans to change the __*() functions to return by default it has not
> > > been implemented yet
>
> > > --
> > > /**
> > > * @author Larry E. Masters
> > > * @var string $userName
> > > * @param string $realName
> > > * @returns string aka PhpNut
> > > * @access  public
> > > */
>
> > > On Thu, Dec 17, 2009 at 12:31 PM, euromark 
> > > wrote:
>
> > > > i do agree that this is one of the few remaining inconsistencies
> > > > remaining in cake1.2/1.3
> > > > all other functions return by default
> > > > e.g. in 1.3 the flash() messages now are returned by default, although
> > > > scripts/css are inline by default (and therefore echod too).
>
> > > > returning should be the default value in most cases
> > > > but i dont think in the __() case this is going to happen :)
> > > > at least it doesnt look like it
>
> > > > using the ___() function might be a very neat way of fixing it for
> > > > you, though
> > > > the overhead is minimal
>
> > > > you should then use the second param though!
> > > > function ___($a, $return = true) { return __($a, $return); }
> > > > to be more flexible
>
> > > > On 17 Dez., 18:39, djogo  wrote:
> > > > > Our previous, cake1.1, code was internationalized using php's gettext
> > > > > library and the function _().
>
> > > > > Cake1.2 now uses __(), which is great, because doesn't require us to
> > > > > "compile" .po files anymore.
>
> > > > > However, the default behaviour of __() is to echo the translated
> > > > > string, instead of returning it, therefore I'm having a lot of heavy
> > > > > work going from _( $a )  to __( $a, true ). I have a regexp for
> > > > > translating _() to __(), but I couldn't figure out how to insert the
> > > > > ",end" parameter in the end of the call.
>
> > > > > I though to create a patch in the __() function to change the default
> > > > > value, but I don't want to have my own "version" of cakephp.
>
> > > > > Or, I may create
>
> > > > > function ___($a) { return __($a,true); }
>
> > > > > I _really_ think cakephp designers should make the second parameters
> > > > > true by default, to turn the transition easy. However, I need my code
> > > > > functioning in CAKE 1.2. Do anybody have some tip?
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers
> > > > 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.comFor
> > > >  more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en

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


Re: Default __() parameters causes problems

2009-12-18 Thread djogo
That's good news indeed.

In which version this feature is planned to be in?

I guess I'll just use a patched version of cake 1.2.5 until this
version comes out.


On Dec 17, 10:45 pm, euromark  wrote:
> nice to hear that
> especially as it is used in controllers, components etc too
> and there the echo default is not that much used :)
>
> On 17 Dez., 19:47, "Larry E. Masters aka PhpNut" 
> wrote:
>
> > I have plans to change the __*() functions to return by default it has not
> > been implemented yet
>
> > --
> > /**
> > * @author Larry E. Masters
> > * @var string $userName
> > * @param string $realName
> > * @returns string aka PhpNut
> > * @access  public
> > */
>
> > On Thu, Dec 17, 2009 at 12:31 PM, euromark 
> > wrote:
>
> > > i do agree that this is one of the few remaining inconsistencies
> > > remaining in cake1.2/1.3
> > > all other functions return by default
> > > e.g. in 1.3 the flash() messages now are returned by default, although
> > > scripts/css are inline by default (and therefore echod too).
>
> > > returning should be the default value in most cases
> > > but i dont think in the __() case this is going to happen :)
> > > at least it doesnt look like it
>
> > > using the ___() function might be a very neat way of fixing it for
> > > you, though
> > > the overhead is minimal
>
> > > you should then use the second param though!
> > > function ___($a, $return = true) { return __($a, $return); }
> > > to be more flexible
>
> > > On 17 Dez., 18:39, djogo  wrote:
> > > > Our previous, cake1.1, code was internationalized using php's gettext
> > > > library and the function _().
>
> > > > Cake1.2 now uses __(), which is great, because doesn't require us to
> > > > "compile" .po files anymore.
>
> > > > However, the default behaviour of __() is to echo the translated
> > > > string, instead of returning it, therefore I'm having a lot of heavy
> > > > work going from _( $a )  to __( $a, true ). I have a regexp for
> > > > translating _() to __(), but I couldn't figure out how to insert the
> > > > ",end" parameter in the end of the call.
>
> > > > I though to create a patch in the __() function to change the default
> > > > value, but I don't want to have my own "version" of cakephp.
>
> > > > Or, I may create
>
> > > > function ___($a) { return __($a,true); }
>
> > > > I _really_ think cakephp designers should make the second parameters
> > > > true by default, to turn the transition easy. However, I need my code
> > > > functioning in CAKE 1.2. Do anybody have some tip?
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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.comFor
> > >  more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=en

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


Re: How to implement Comet in CakePHP ?

2009-12-18 Thread nacho4d
I have been search this (comet in cakephp) for some time, but I
couldn't find anything really helpful
I would appreciate your help. ;)


On Dec 17, 5:22 pm, cherif_Gsoul  wrote:
> hi, you have to learn more about cakephp is not so hard to learn
> ajax's implementation in  cakephp who is made to work with the
> prototype framework and ther's a helper for jquery developed by the
> community i think, i saw one day a plugin for tchat somewhere do some
> google researchs i am sur you will get it. i do some research if i
> find something i ll post it here ok?
>  tciao.

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


Re: Help with Redirect

2009-12-18 Thread Foroct
I'm in the same boat as Dewayne.

If you are on the edit page for that product and click submit doesnt
the product id get passed into the controller?  If so then the
redirect specified
 $this->redirect(array('controller' => 'compatibles', 'action' =>
'index',
'product_id' => $product_id));

should put you on /compatibles/index/$product_id with $product_id
being something like 123

If the product id doesn't get passed back to the controller how would
you go about making that happen?



On Dec 17, 5:57 pm, Miles J  wrote:
> Redirect does not redirect you to the previous page. If you don't have
> the ID to the page you want to redirect to, then you cant redirect to
> it.
>
> You need to save that ID somewhere if you want to use it.
>
> On Dec 17, 2:01 pm, Dewayne Pinion  wrote:
>
> > No luck so far. The http_referrer just stayed on the edit page. Using the
> > code below, I saw null. I did see in the code that I had $id instead, but
> > when I echoed it the id was the related product that I was editing, not the
> > main product page.
>
> > On Thu, Dec 17, 2009 at 4:48 PM, Andras Kende  wrote:
> > > echo 'product_id is: ' . $product_id;
> > > die();
>
> > --
> > Dewayne Pinion
> > Web/Software Guy
> > Trenton Technologyhttp://www.trentontechnology.com

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread robustsolution
m sorry, captcha plugin is also considered as a very small separate
application plugin, I gave a wrong example.

but you still have the option number 2 but you need to specify the
plugin key/prefix in the url array/string


On Dec 18, 1:54 pm, robustsolution  wrote:
> AFAIK,
>
> plugin could be used
>
> -1-to be a ~~~separate application : example the blog plugin, the auth
> plugin, the forum plugin, etc...
> -2-to be called from anywhere by using a requestAction: example
> captcha plugin is used to be called via requestAction to import the
> "prove that you are human" image
>
> choose the option you need (you may use number 2)
>
> and have a nice baking day
>
> On Dec 18, 12:53 pm, Aargh  wrote:
>
> > I would like to know if there is any official (or at least supported /
> > under development) mechanism that would allow me to create hooks so
> > that i can hook certain plugin functions into a controller.
>
> > What would be sweet :
>
> > Controller hooks
>
> > For example let-s say we have a two statistics plugins. One checks the
> > ip, one checks the searchphrase. They both basically work with the
> > same data, and could be hooked into the afterFilter or smth.
>
> > So the idea would be to be able to register a hook, and then (using
> > naming conventions ??), certain (plugin) functions to be called.
>
> > View hooks
>
> > Would be great such thing to also exist for the views, let-s say we
> > register a viewHook called "product_addons", so if we develop a "rate
> > the product" plugin, the view would take a ctp from the plugin and
> > render the stars and the rating form in that hook. And of course when
> > disabling the plugin, searching for the things to be rendered there
> > will return empty. Whatever.
>
> > I've seen something like (controllerHooks) this at Tarique Sani's
> > Cheesecake, in his hitStats plugin. It has some AppInit component that
> > will do the hooks. I'm not sure how it works, I've not investgated
> > further as the software seems to be quite old (1.1 framework version I
> > think). There was another implementation like this called SpliceIt,
> > but is not mantained, and seems quite old also.
>
> > Is there any reccomended way of actually plugging/unplugging custom
> > logic ? Because the plugins seem more like separate apps (that can use
> > the main's app logic, and not the other way arround, which is ok after
> > all) to me. Maybe I missed something, but I can't find a way to
> > elegantly plug in/out custom logic into the controllers.
>
> > For plugging in/out custom elements/views i didn't find anything :(.
>
> > Probably doing this in models is wrong by design.
>
> > Maybe I have some brain damage from other apps I modified. But there
> > are plenty of components and helpers that make development a breeze,
> > until you need to actually do a plugin that can also easly plug out.
> > This is one of the reasons I think apps like wordpress, prestashop and
> > similar have a bigger community than any cakephp based app outhere
> > (for example CheeseCake is a good photoblog, but without other (spam
> > filtering for example) plugins is not to be considered by most
> > photographers out there, and noone is willing to create one if there
> > is no standard way to develop plugins in cakphp, and everytime you
> > have to rediscover how the developer implemented the hooks). I think
> > this would make easier for us to port plugins from one app to another,
> > thus making creation of feature rich software easier.
>
> > Is very hard to do anything but custom software on cakephp, as for
> > example creating a good shopping cart will essentially rule out 3'rd
> > parties from developing payment or shipping plugins. Most of those
> > payment plugins for example do the same thing, but using different
> > apis. From the cart's point of view they all act the same, send a
> > form, receive an answer, update the cart's status. But there is no
> > elegant way to plug in/out these modules. And the funny thing is most
> > of them do not even need a table, just a form and a way to validate
> > the answer and change cart's status.
>
> > Some time ago I developed some publishing software with cake (1.1). It
> > was great, until it came to statistics. I had to add lots of
> > requestActions in the before and afterFilters. Right now is some kind
> > of mess (as removong a "plugin" would also mean to remove the added
> > logic into the main apps controllers and views). The next thing I
> > develop I would like to not become so messy.
>
> > (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
> > resize helper spared me a lot of work, 10x god the community is
> > strugling to add cool functionality to the framework).
>
> > I searched about this topics, but I didn't find much. I checked
> > various apps for ideas, but most of them are outdated.
>
> > Is there anything like this in plan ? Is there any component that
> > already do that ?

Check out the new CakePHP Questions site http://ca

Re: Database encryption & security

2009-12-18 Thread robustsolution
of course you are talking about two-way encryption not hashing (one
way).

by the way what do you mean by the database owner?

either the guy have a full access to the database or a custom access.

if you are the one who has full access, give him a mysql account with
custom access to all tables except the tables that have sensitive
info.

otherwise an alternative solution should be required here.

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


Re: Plugin callbacks and controller hooks

2009-12-18 Thread robustsolution
AFAIK,

plugin could be used

-1-to be a ~~~separate application : example the blog plugin, the auth
plugin, the forum plugin, etc...
-2-to be called from anywhere by using a requestAction: example
captcha plugin is used to be called via requestAction to import the
"prove that you are human" image

choose the option you need (you may use number 2)

and have a nice baking day


On Dec 18, 12:53 pm, Aargh  wrote:
> I would like to know if there is any official (or at least supported /
> under development) mechanism that would allow me to create hooks so
> that i can hook certain plugin functions into a controller.
>
> What would be sweet :
>
> Controller hooks
>
> For example let-s say we have a two statistics plugins. One checks the
> ip, one checks the searchphrase. They both basically work with the
> same data, and could be hooked into the afterFilter or smth.
>
> So the idea would be to be able to register a hook, and then (using
> naming conventions ??), certain (plugin) functions to be called.
>
> View hooks
>
> Would be great such thing to also exist for the views, let-s say we
> register a viewHook called "product_addons", so if we develop a "rate
> the product" plugin, the view would take a ctp from the plugin and
> render the stars and the rating form in that hook. And of course when
> disabling the plugin, searching for the things to be rendered there
> will return empty. Whatever.
>
> I've seen something like (controllerHooks) this at Tarique Sani's
> Cheesecake, in his hitStats plugin. It has some AppInit component that
> will do the hooks. I'm not sure how it works, I've not investgated
> further as the software seems to be quite old (1.1 framework version I
> think). There was another implementation like this called SpliceIt,
> but is not mantained, and seems quite old also.
>
> Is there any reccomended way of actually plugging/unplugging custom
> logic ? Because the plugins seem more like separate apps (that can use
> the main's app logic, and not the other way arround, which is ok after
> all) to me. Maybe I missed something, but I can't find a way to
> elegantly plug in/out custom logic into the controllers.
>
> For plugging in/out custom elements/views i didn't find anything :(.
>
> Probably doing this in models is wrong by design.
>
> Maybe I have some brain damage from other apps I modified. But there
> are plenty of components and helpers that make development a breeze,
> until you need to actually do a plugin that can also easly plug out.
> This is one of the reasons I think apps like wordpress, prestashop and
> similar have a bigger community than any cakephp based app outhere
> (for example CheeseCake is a good photoblog, but without other (spam
> filtering for example) plugins is not to be considered by most
> photographers out there, and noone is willing to create one if there
> is no standard way to develop plugins in cakphp, and everytime you
> have to rediscover how the developer implemented the hooks). I think
> this would make easier for us to port plugins from one app to another,
> thus making creation of feature rich software easier.
>
> Is very hard to do anything but custom software on cakephp, as for
> example creating a good shopping cart will essentially rule out 3'rd
> parties from developing payment or shipping plugins. Most of those
> payment plugins for example do the same thing, but using different
> apis. From the cart's point of view they all act the same, send a
> form, receive an answer, update the cart's status. But there is no
> elegant way to plug in/out these modules. And the funny thing is most
> of them do not even need a table, just a form and a way to validate
> the answer and change cart's status.
>
> Some time ago I developed some publishing software with cake (1.1). It
> was great, until it came to statistics. I had to add lots of
> requestActions in the before and afterFilters. Right now is some kind
> of mess (as removong a "plugin" would also mean to remove the added
> logic into the main apps controllers and views). The next thing I
> develop I would like to not become so messy.
>
> (Btw, sluggable behaviour, bindable behaviour, meio upload and magick
> resize helper spared me a lot of work, 10x god the community is
> strugling to add cool functionality to the framework).
>
> I searched about this topics, but I didn't find much. I checked
> various apps for ideas, but most of them are outdated.
>
> Is there anything like this in plan ? Is there any component that
> already do that ?

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


Re: Authentication (cookies?) across different domains

2009-12-18 Thread Chad Smith
I have to completely agree with John here, set it as a subdomains.
That way you have http://italian.mysite.com, http://www.mysite.com
(english), http://french.mysite.com ... or you can always do
http://it.mysite.com, http://en.mysite.com, http://fr.mysite.com

Either way here's how you set the session to flow between any
subdomains you have.

In your config/bootstrap.php file put this in:
ini_set("session.cookie_domain", ".mysite.com");

// Of course change mysite.com to whatever your domain is.

Then within config/core.php change to:
Configure::write('Security.level', 'low');


That's how you can pass around the session variables,
Chad

On Dec 17, 3:51 am, John Andersen  wrote:
> Hi Daniel,
>
> I can understand that you want to be able to change the language,
> depending on the users wish, so that an italian in england can read
> the site in italian.
>
> But my question is more about the content - will the content be
> dependent on the language or the domain extension - for example:
> [example case]
> An italian in england starts the site at .com and get the english
> content. The italian switches to .it to get the italian content. But
> will the content be from england or from italy? That is, is the
> content dependent on the extension? If yes, then you can't use the
> extension as a language indicator :)
> [/example case]
>
> So your idea of subdomains may be better, in case you in the future
> wants to make the site content dependent on the country (extension)!
>
> Hope the above helps you a little :)
>    John
>
> On Dec 16, 3:44 pm, cakeFreak  wrote:> Hey John,
>
> > well the italian site will display news and all other content in
> > Italian, while the .com in English.
>
> > The other solution I have is to use subdomains: it.mysite.com |
> > en.mysite.com
>
> > Daniel
>
> > On 16 Dic, 14:18, John Andersen  wrote:
>
> > > Is that a good idea?
>
> > > What about the content? Will the content be for Italy also, when the
> > > domain is .it?
>
> > > Can you describe your site and what changes will happen to the
> > > content, when a user changes the domain extension?
>
> > > Enjoy,
> > >    John
>
> > > On Dec 10, 4:48 pm, cakeFreak  wrote:
>
> > > > Hey guys,
>
> > > > developing a multilanguage application I thought to have different
> > > > languages according to the domain extension:
>
> > > > i.e.
> > > > mysite.com => english
> > > > mysite.it      => italian
>
> > > > How can I keep the user authenticated across the 2 domains via
> > > > cookies?
>
> > > > ---
> > > > I know that with subdomains you can just set the cookie config as
> > > > follows:
>
> > > >http://book.cakephp.org/view/179/Controller-Setup
>
> > > > setting
>
> > > > $this->Cookie->domain = '*.example.com';
>
> > > > ---
>
> > > > Cheers
>
> > > > Dan

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


Re: Can I initialize a component within a function?

2009-12-18 Thread euromark
well right, manja,
i forgot that part - and sometimes you need init() too

but there are components which dont have init() or startup()
then you dont need to pass the controller as reference


On 18 Dez., 14:14, majna  wrote:
> You can put this method this in app_controller for cleaner 
> importhttp://bin.cakephp.org/view/1494579178
>
> On Dec 18, 12:13 pm, number9  wrote:
>
> > Thanks very much for the replies guys thats worked great, I knew there
> > must have been some way of doing it!
>
> > On Dec 18, 10:28 am, majna  wrote:
>
> > > ..and add Controller reference:
>
> > > App::import('Component', 'Own');
> > > $this->Own = new OwnComponent();
> > > $this->Own->startup($this);
>
> > > On Dec 18, 1:16 am, euromark  wrote:
>
> > > > sure
> > > > nothing easier than that
>
> > > > App::import('Component', 'Own');
> > > > $this->Own = new OwnComponent();
>
> > > > On 17 Dez., 22:28, number9  wrote:
>
> > > > > I'm using the flickr api component within an app and it is working
> > > > > great, but for some reason it is causing a foreach loop to not work (I
> > > > > have no idea why).
>
> > > > > At the moment I have initialized the component as follows:
>
> > > > >         var $components = array('Flickr');
>
> > > > > Is there any way I can replicate that within a function such as:
>
> > > > > function index()
> > > > > {
> > > > >    // Include component here...
>
> > > > > }
>
> > > > > In this way I can avoid the clash with the for each loop!
>
> > > > > Thanks in advance.

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


Re: Can I initialize a component within a function?

2009-12-18 Thread majna
You can put this method this in app_controller for cleaner import
http://bin.cakephp.org/view/1494579178

On Dec 18, 12:13 pm, number9  wrote:
> Thanks very much for the replies guys thats worked great, I knew there
> must have been some way of doing it!
>
> On Dec 18, 10:28 am, majna  wrote:
>
> > ..and add Controller reference:
>
> > App::import('Component', 'Own');
> > $this->Own = new OwnComponent();
> > $this->Own->startup($this);
>
> > On Dec 18, 1:16 am, euromark  wrote:
>
> > > sure
> > > nothing easier than that
>
> > > App::import('Component', 'Own');
> > > $this->Own = new OwnComponent();
>
> > > On 17 Dez., 22:28, number9  wrote:
>
> > > > I'm using the flickr api component within an app and it is working
> > > > great, but for some reason it is causing a foreach loop to not work (I
> > > > have no idea why).
>
> > > > At the moment I have initialized the component as follows:
>
> > > >         var $components = array('Flickr');
>
> > > > Is there any way I can replicate that within a function such as:
>
> > > > function index()
> > > > {
> > > >    // Include component here...
>
> > > > }
>
> > > > In this way I can avoid the clash with the for each loop!
>
> > > > Thanks in advance.
>
>

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


Re: cache prefix

2009-12-18 Thread Kawina
Any help? Thanks.

On Dec 17, 9:12 am, Kawina  wrote:
> I'm new to CakePHP and my little knowledge is derived from  minor
> modifications to an app created by someone else. Accordingly, my
> familiarity with the cache system is limited.
>
> My search of this group on the issue only yielded old bugs that I hope
> have been subsequently fixed.
>
> I tried adding a prefix in /app/config/core.php. I changed it in
> accordance with the documentation as follows:
> Original: Cache::config('default', array('engine' => 'File', 'path' =>
> CACHE) );
> Change: Cache::config('default', array('engine' => 'File', 'path' =>
> CACHE, 'prefix' => 'uat_') );
>
> However, that has had no effect. A typical cache file looks like this:
> cake_core_default_eng (in /persistent).
>
> I'm surprised by the "cake_" prefix. Is that the default when no
> prefix is defined?
>
> Are there other files to modify? Is it possible that the configuration
> is in a cache file that should be deleted, and if so which one?

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


Plugin callbacks and controller hooks

2009-12-18 Thread Aargh
I would like to know if there is any official (or at least supported /
under development) mechanism that would allow me to create hooks so
that i can hook certain plugin functions into a controller.

What would be sweet :

Controller hooks

For example let-s say we have a two statistics plugins. One checks the
ip, one checks the searchphrase. They both basically work with the
same data, and could be hooked into the afterFilter or smth.

So the idea would be to be able to register a hook, and then (using
naming conventions ??), certain (plugin) functions to be called.

View hooks

Would be great such thing to also exist for the views, let-s say we
register a viewHook called "product_addons", so if we develop a "rate
the product" plugin, the view would take a ctp from the plugin and
render the stars and the rating form in that hook. And of course when
disabling the plugin, searching for the things to be rendered there
will return empty. Whatever.

I've seen something like (controllerHooks) this at Tarique Sani's
Cheesecake, in his hitStats plugin. It has some AppInit component that
will do the hooks. I'm not sure how it works, I've not investgated
further as the software seems to be quite old (1.1 framework version I
think). There was another implementation like this called SpliceIt,
but is not mantained, and seems quite old also.

Is there any reccomended way of actually plugging/unplugging custom
logic ? Because the plugins seem more like separate apps (that can use
the main's app logic, and not the other way arround, which is ok after
all) to me. Maybe I missed something, but I can't find a way to
elegantly plug in/out custom logic into the controllers.

For plugging in/out custom elements/views i didn't find anything :(.

Probably doing this in models is wrong by design.

Maybe I have some brain damage from other apps I modified. But there
are plenty of components and helpers that make development a breeze,
until you need to actually do a plugin that can also easly plug out.
This is one of the reasons I think apps like wordpress, prestashop and
similar have a bigger community than any cakephp based app outhere
(for example CheeseCake is a good photoblog, but without other (spam
filtering for example) plugins is not to be considered by most
photographers out there, and noone is willing to create one if there
is no standard way to develop plugins in cakphp, and everytime you
have to rediscover how the developer implemented the hooks). I think
this would make easier for us to port plugins from one app to another,
thus making creation of feature rich software easier.

Is very hard to do anything but custom software on cakephp, as for
example creating a good shopping cart will essentially rule out 3'rd
parties from developing payment or shipping plugins. Most of those
payment plugins for example do the same thing, but using different
apis. From the cart's point of view they all act the same, send a
form, receive an answer, update the cart's status. But there is no
elegant way to plug in/out these modules. And the funny thing is most
of them do not even need a table, just a form and a way to validate
the answer and change cart's status.

Some time ago I developed some publishing software with cake (1.1). It
was great, until it came to statistics. I had to add lots of
requestActions in the before and afterFilters. Right now is some kind
of mess (as removong a "plugin" would also mean to remove the added
logic into the main apps controllers and views). The next thing I
develop I would like to not become so messy.

(Btw, sluggable behaviour, bindable behaviour, meio upload and magick
resize helper spared me a lot of work, 10x god the community is
strugling to add cool functionality to the framework).

I searched about this topics, but I didn't find much. I checked
various apps for ideas, but most of them are outdated.

Is there anything like this in plan ? Is there any component that
already do that ?

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


Best practise to manage user's selections and user's views

2009-12-18 Thread marco.rizze...@gmail.com
Hi
In my application I have the model "Item" and the model "User".
Every item is visible by some users and it isn't visible by other
users. So I have a HABTM between "User" and "Item".
Now I must register when a user views an item and when a user selects
a item (a user can select some visible items if he wants).
To do this I have found 2 solutions:
1)  Created two models "ItemSelection" and "ItemView" but if I must
use INNER JOIN (for example If I would the list(with paginate) of
users that have viewed and selected and certainly item)  I have very
very bad performance.
2)  Add to the users_items table fields "viewed" and "selected" but I
have a big table with many and many record with null value

I would ask if someone has this problom in the past and how he has
resolved it.
Many Thanks
Bye

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


Re: Can I initialize a component within a function?

2009-12-18 Thread number9
Thanks very much for the replies guys thats worked great, I knew there
must have been some way of doing it!

On Dec 18, 10:28 am, majna  wrote:
> ..and add Controller reference:
>
> App::import('Component', 'Own');
> $this->Own = new OwnComponent();
> $this->Own->startup($this);
>
> On Dec 18, 1:16 am, euromark  wrote:
>
>
>
> > sure
> > nothing easier than that
>
> > App::import('Component', 'Own');
> > $this->Own = new OwnComponent();
>
> > On 17 Dez., 22:28, number9  wrote:
>
> > > I'm using the flickr api component within an app and it is working
> > > great, but for some reason it is causing a foreach loop to not work (I
> > > have no idea why).
>
> > > At the moment I have initialized the component as follows:
>
> > >         var $components = array('Flickr');
>
> > > Is there any way I can replicate that within a function such as:
>
> > > function index()
> > > {
> > >    // Include component here...
>
> > > }
>
> > > In this way I can avoid the clash with the for each loop!
>
> > > Thanks in advance.

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


Database encryption & security

2009-12-18 Thread WhyNotSmile
Hi,

I was wondering whether anyone could help me out with some database
encryption.  The app stores a bit of personal info in the MySQL
database - name, address, phone number, email address & password.  I
think I should probably encrypt this in the database so that even the
owner of the database can't see the information there.

I don't think security will be a huge issue, but all the same I think
it would be good to put something in place.

Anyway, I have looked online and can't really find anything to help me
- it's all a bit too advanced for my needs!  I thought there would be
a simple way of doing this, but I can't find one.

Basically, what I want is when Cake saves the data, it encrypts it
first, and then decrypts it when it loads it back in.  I was sure I'd
read this in the manual, but can't find it now!  There is stuff in
there about salt values, but I don't understand how that works (and
anyway, I set the salt value, and it clearly doesn't cause my data to
encrypt!).

It doesn't have to encrypt absolutely everything (some of it is just
random info), but if it is easier to just do the lot, then that's
grand.  Also, the data is in UTF-8, if that makes any difference.

So if someone could point me in the right direction, I'd be very
grateful.

Thank you.

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


Count column in index view

2009-12-18 Thread Jeremy Burns
I have a model that uses the Tree behaviour, so it has a self join in
the database (parent_id to id). In my index view I'd like to add a
column that shows the count of direct children for 'this' row. I know
I can get that number on a row by row basis using childCount, but how
do I use that as part of my contain and pagination?

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


Re: Caching a pagination data

2009-12-18 Thread HK
Thanks a lot!!!

How stupid of me! I didn't include the Cache helper.

On Dec 18, 11:00 am, robustsolution  wrote:
> I meant why arent you using the cache helper...etc
>
> On Dec 18, 8:58 am, robustsolution  wrote:
>
> > hi HK,
> > Aren't you the cache helper in the controller? because AFAIK it should
> > be used also.
>
> > caching view is something server-side (done on the server), it caches
> > the whole (browser request)'s page answer (the html source code)
>
> > caching images is another thing, it is something done on the client
> > side (in the browser cache), you may treat the image as an asset file
> > (like css files or js files) to force caching it in the client side.
>
> > as for caching just the returned value of the $this->paginate, you may
> > use this amazing linkhttp://book.cakephp.org/complete/764/Cache
>
> > have a nice baking day
>
> > On Dec 18, 7:56 am, HK  wrote:
>
> > > Hello all,
>
> > > I have a function in my controller which reads about 4000-8000 images
> > > (depending on the event viewed) and then return a pagination. Since
> > > those images don't change per event I would like to cache them.
>
> > > First of all can I use view cache? I enabled cache in core.php, and
> > > use $this->cacheAction=true in my action.
> > > app/tmp is writable (chmod -R 777) but no page appears on tmp/cache/
> > > view only the empty file. Is it because I use $this->paginate()?
>
> > > Can pagination work with cache?
>
> > > Another solution would be to cache $this->paginate() so not to fetch
> > > data on every request. Can this be done, and how?
>
> > > thanks a lot

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


Re: Can I initialize a component within a function?

2009-12-18 Thread majna
..and add Controller reference:

App::import('Component', 'Own');
$this->Own = new OwnComponent();
$this->Own->startup($this);

On Dec 18, 1:16 am, euromark  wrote:
> sure
> nothing easier than that
>
> App::import('Component', 'Own');
> $this->Own = new OwnComponent();
>
> On 17 Dez., 22:28, number9  wrote:
>
> > I'm using the flickr api component within an app and it is working
> > great, but for some reason it is causing a foreach loop to not work (I
> > have no idea why).
>
> > At the moment I have initialized the component as follows:
>
> >         var $components = array('Flickr');
>
> > Is there any way I can replicate that within a function such as:
>
> > function index()
> > {
> >    // Include component here...
>
> > }
>
> > In this way I can avoid the clash with the for each loop!
>
> > Thanks in advance.
>
>

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


Re: Caching a pagination data

2009-12-18 Thread robustsolution
I meant why arent you using the cache helper...etc

On Dec 18, 8:58 am, robustsolution  wrote:
> hi HK,
> Aren't you the cache helper in the controller? because AFAIK it should
> be used also.
>
> caching view is something server-side (done on the server), it caches
> the whole (browser request)'s page answer (the html source code)
>
> caching images is another thing, it is something done on the client
> side (in the browser cache), you may treat the image as an asset file
> (like css files or js files) to force caching it in the client side.
>
> as for caching just the returned value of the $this->paginate, you may
> use this amazing linkhttp://book.cakephp.org/complete/764/Cache
>
> have a nice baking day
>
> On Dec 18, 7:56 am, HK  wrote:
>
> > Hello all,
>
> > I have a function in my controller which reads about 4000-8000 images
> > (depending on the event viewed) and then return a pagination. Since
> > those images don't change per event I would like to cache them.
>
> > First of all can I use view cache? I enabled cache in core.php, and
> > use $this->cacheAction=true in my action.
> > app/tmp is writable (chmod -R 777) but no page appears on tmp/cache/
> > view only the empty file. Is it because I use $this->paginate()?
>
> > Can pagination work with cache?
>
> > Another solution would be to cache $this->paginate() so not to fetch
> > data on every request. Can this be done, and how?
>
> > thanks a lot

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


Re: Caching a pagination data

2009-12-18 Thread robustsolution
hi HK,
Aren't you the cache helper in the controller? because AFAIK it should
be used also.

caching view is something server-side (done on the server), it caches
the whole (browser request)'s page answer (the html source code)

caching images is another thing, it is something done on the client
side (in the browser cache), you may treat the image as an asset file
(like css files or js files) to force caching it in the client side.

as for caching just the returned value of the $this->paginate, you may
use this amazing link
http://book.cakephp.org/complete/764/Cache

have a nice baking day

On Dec 18, 7:56 am, HK  wrote:
> Hello all,
>
> I have a function in my controller which reads about 4000-8000 images
> (depending on the event viewed) and then return a pagination. Since
> those images don't change per event I would like to cache them.
>
> First of all can I use view cache? I enabled cache in core.php, and
> use $this->cacheAction=true in my action.
> app/tmp is writable (chmod -R 777) but no page appears on tmp/cache/
> view only the empty file. Is it because I use $this->paginate()?
>
> Can pagination work with cache?
>
> Another solution would be to cache $this->paginate() so not to fetch
> data on every request. Can this be done, and how?
>
> thanks a lot

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