Tuesday, November 30, 2010

Re: Problem with Math Captcha component @ 1.3.6

I focused on this function:

function validate($data) {
if ($data == $this->Session->read('MathCaptcha.answer')){
return true;
}
}

$data exists
$this->Session->read('MathCaptcha.answer') exists


Why this function does not return 'true' when called from controller
with the following code

if ($this->MathCaptcha->validate($this->data['Contact']
['security_code'])) {
------
}

$this->data['Contact']['security_code'] exists

Thanks :)

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

Re: Multiple excel sheet download

Thanks buddy! Will do.

On Nov 26, 7:45 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 11:08 AM, the plumpNation <plumpnat...@gmail.com> wrote:
> > Hi guys,
>
> > I have a sales report in excel which is generated using cakephp and
> >PHPExcel. I am very happy with both of these frameworks/libraries. I
> > am really starting to feel very comfortable using them both and am
> > finally getting to the stage of being able to 'rapidly develop', the
> > whole point of cake.
>
> > Currently, the sales are generated from customers who share
> > distributors. So the logic goes
>
> > foreach(distributor){
> >   // create excel of sales using this distributor;
> >   // send email with sales to this distributor;
> > }
>
> > Then I added functionality to allow the sales manager to download the
> > sheet just to check it, before the cron ran and sent it to the
> > distributors.
>
> > foreach(distributor){
> >   // create excel of sales using this distributor;
> >  if(!browserOutput){
> >   // send email with sales to this distributor;
> >  }else{
> >  // output the excel sheet to the browser;
> >  }
> > }
>
> > Now it all works fine except that I only receive the first sheet,
> > probably because you can't do a looping download. I was just wondering
> > if anyone had an elegant solution to this that didn't involve me
> > writing the sheets to different tabs in the same excel sheet, but
> > allows the manager to receive all the sheets from the browser one at a
> > time. Maybe opening the output in different tabs or windows might
> > work, but not sure how to do this. At the moment I set headers to the
> > correct mime type like so
>
> > if($browserOutput){
>
> >                                $message .= 'for output to browser<br />';
> >                                header( 'Content-Type: application/vnd.ms-excel' );
> >                                header( 'Content-Disposition: attachment;filename="' . $filename .
> > '"');
> >                                header( 'Cache-Control: max-age=0' );
>
> >                        }
>
> > and then usePHPExcellike so
>
> > $thisSheet->save('php://output');
>
> > Whatcha fink? Is this possible or should I write all the sheets into
> > one file to download?
>
> Yes, write them all to a single file. I think that makes more sense if
> the data is all related. I suppose you could write several sheets as
> separate files, zip them up, and then output that. But that seems a
> bit strange as the sheets are already part of the same file. UsePHPExcel::createSheet().

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

Re: $_SESSION contains my data but $Session helper is empty.

Actually, after about a day of mucking around in the core, I solved
the problem. It is just a little "gotcha" with the way Cake loads
start_session(), or so it seems.

I've reproduced the bug with a clean copy of Cake 1.3.6. The reason
why the Session helper fails is only if you have browser output (like
debug output) in the beforeFilter() function of AppController or
anywhere sooner in the dispatching process.

To test, just type some pr() statement in
AppController::beforeFilter(), and then try to reproduce my original
problem above, and you'll see that the Session helper fails. BUT, if
you put something like $this->Session->check('blah') (even if 'blah'
is a nonexistent session key) BEFORE your pr() statement in
beforeFilter(), then the Session helper succeeds.

I believe the reason is because session_start() is not called early
enough in the application, but seems to be called on the first
instance of using the Session component (or helper), and if headers
have already been sent to the browser, session_start() fails. (Though
it is failing silently with my PHP error reporting set to ALL.)

Yuck! I'm glad I solved it though. I've reported issue in Lighthouse.

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

Problem with Math Captcha component @ 1.3.6

Hello, i trying to use this small piece of code

http://jamienay.com/2009/06/math-captcha-component/

here its my code:
###############################################################

MODEL:

class Contact extends AppModel {
var $name = 'Contact';
var $useTable = false;

var $_schema = array(
'name' =>array('type' => 'string', 'length' => 100),
'email' =>array('type' => 'string', 'length' => 255),
'subject' =>array('type' => 'string', 'length' => 255),
'message' =>array('type' => 'text')
);

var $validate = array(
'name' => array('minLength' => array('rule' =>
array('minLength', 3))),
'email' => array('email' => array('rule' => 'email')),
'subject' => array('notempty' => array('rule'=>'notempty')),
'message' => array('minLength' => array('rule' =>
array('minLength', 60)))
);

}
###########################################################

Controller:
....
var $components = array('RequestHandler', 'Email', 'Session',
'MathCaptcha');

function index() {
$this->set('controller_name', __('Contact',true));
$this->set('action_name', __('Index',true));
if ($this->RequestHandler->isPost()) {
$this->Contact->set($this->data);
if ($this->MathCaptcha->validates($this->data['Contact']
['security_code'])) {
if ($this->Contact->validates()) {
$this->Email->to =
Configure::read('Setting.Site.email') ;
$this->Email->subject = $this->data['Contact']
['subject'];
$this->Email->from = $this->data['Contact']['email'];
$this->Email->send($this->data['Contact']['message']);
}

}else {
$this->Session->setFlash(__('Please enter the correct
answer to the math question.', true));
}
}
$this->set('mathCaptcha', $this->MathCaptcha-
>generateEquation());
}

######################################################

view

<?php
echo $this->Form->input('name',array('label'=>__('Your
Name',true),'error'=>array('minLength'=>__('You must enter your full
name!',true))));
echo $this->Form-
>input('email',array('error'=>array('email'=>__('Please enter your
valid email!',true))));
echo $this->Form->input('subject',array('options'=>array(null
=>__('-- Choose One --',true),

__('Jobs',true)=>__('Jobs',true),

__('Orders',true)=>__('Orders',true),

__('Products',true)=>__('Products',true),

__('Brands',true)=>__('Brands',true),

__('Services',true)=>__('Services',true),

__('Partners',true)=>__('Partner',true),

__('Promotion',true)=>__('Promotion',true),

__('Other',true)=>__('Other',true)),
'label'=>__('Type of
message',true),

'error'=>array('notempty'=>__('Please choose one',true))));
echo $this->Form-
>input('message',array('type'=>'textarea','label'=>__('Message',true),'error'=>array('minLength'=>__('Your
message is to short!',true))));
echo $form->input('security_code', array('label' => __('Please
Enter the Sum of ',true) . $mathCaptcha));
?>


I detected a problem in the components, function registerAnswer not
work as intended, that does not set the session.

Help me to solve a problem:)

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

Re: CakePlate - Boilerplate CakePHP distro

Great work.
I also recommend adding something like packages.
Multilingual package
Reports package that will include excel and pdf libs for data export
etc.

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

Migrating from CakePHP 1.1 - Yikes?!

Hi,

I have a web-application written in CakePHP 1.1 which is non-trivial
and where I was not the original developer. I am just getting back
into this project now and picking it up off the ground.

I am wondering how painful it will be for me to migrate to the latest
version of CakePHP (1.3) ? I realize its a factor of the code
(details), my skills and the needs/longevity of the application - but
whats your gut feeling for a 30000+ LOC typical business app for an
senior engineer (intermediate php developer)?

Maybe I should just limp it along under 1.1?

Thanks.

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

Retrieving Posts with comments

Hello

i have a simple app that's very similar to the cookbook "Blog"
tutorial

i want to retrieve all Posts having at least one comment.

right now i'm doing this way:

$posts = $this->Post->find("all", array("contain" =>
array("Comment"));
foreach ($posts as $index => $post) {
if (empty($post["Comment"])) unset $posts[$index];
}

is there any way to achieve this by using a single ->find() call?

notes: i'm using Containable.

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