Re: how to extract filesize from meioupload with understable format ?

2012-01-15 Thread ahmed fakher
thanls 100rk it is work now

On Jan 16, 12:45 am, 100rk  wrote:
> http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#Num...

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


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


Re: how to extract filesize from meioupload with understable format ?

2012-01-15 Thread ahmed fakher
thanks 100rk but i use cakephp1.3
is this anyway to use with 1.3?

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


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


SwiftMailer Component not working CakePHP 2.0.5

2012-01-15 Thread Craig Brandt
Hi All,

I have followed the guide on the Cake Bakery using the the SwiftMailer
component:

http://bakery.cakephp.org/articles/rajibahmed/2011/02/23/cakephp_swiftmailer4_x_x_component_with_batch_send

I have followed the instructions but keep getting 'failed to send
email: SwiftMailer was not included, check the path and filename'. I
am aware that the CakePHP 2.0 has changed the Class Loading syntax as
indicated in the migration guide but I am having no success. I have
amended the following line in /app/Controllers/Components/
SwiftMailerComponent.php as per CakePHP 2.0.5 requirements:
App::uses('Swift', array('file' => 'lib'.DS.'swift_required.php',
'Vendor'));
The location of the Swift Library is /app/Vendor/Swift/lib/
swift_required.php.

Any help would be highly appreciated.

Thanks,

Craig

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread jeremyharris
Oh you *want* users to be able to edit, but just themselves?

Then the code I posted in the first reply should work. If you want admin to 
be able to edit, you can either do a separate action / prefixed action, or 
do the check within the method (or a separate function to check). 
isAuthorized isn't probably the place for a check like that, since it 
doesn't know what the id's you are editing are.

Something like

public function delete($id) {
$id = isEditable($id);
// etc
}

private function isEditable($id) {
if ($this->Auth->user('group_id') == 1) {
// they are admin, so return the original id they wanted to edit
return $id;
}
// they are not admin, so return their user id
return $this->Auth->user('id');
}

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


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


Re: how to extract filesize from meioupload with understable format ?

2012-01-15 Thread 100rk
http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::toReadableSize

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


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


Re: how to extract filesize from meioupload with understable format ?

2012-01-15 Thread ahmed fakher
how to format it to an human readable format

On Jan 15, 9:13 pm, Thiago Belem  wrote:
> You should save the size in bytes and format it to an human readable format
> (2 mb) on the view, with a helper.
>
> --
> Thiago Belem,
> Desenvolvedor WEB
>
> Enviado do meu Android
> Em 15/01/2012 14:59, "ahmed fakher"  escreveu:
>
>
>
>
>
>
>
> > i use meioupload behavior to upload files but i cant know how to sive
> > filesize with nice format like (2 mb , 10 kb) ..i see this function in
> > meioupload but i dont know how to use it
>
> > /**
> >     * Convert a size value to bytes. For example: 2 MB to 2097152.
> >     *
> >     * @author Vinicius Mendes
> >     * @return int
> >     * @param $size String
> >     */
> >    function sizeToBytes($size){
> >        if(is_numeric($size)) return $size;
> >        if(!preg_match('/^[1-9][0-9]* (kb|mb|gb|tb)$/i', $size)){
> >            trigger_error('MeioUploadBehavior Error: The max_size
> > option format is invalid.', E_USER_ERROR);
> >            return 0;
> >        }
> >        list($size, $unit) = explode(' ',$size);
> >        if(strtolower($unit) == 'kb') return $size*1024;
> >        if(strtolower($unit) == 'mb') return $size*1048576;
> >        if(strtolower($unit) == 'gb') return $size*1073741824;
> >        if(strtolower($unit) == 'tb') return $size*1099511627776;
> >        trigger_error('MeioUploadBehavior Error: The max_size unit is
> > invalid.', E_USER_ERROR);
> >        return 0;
> >    }
>
> > to upload new file downloads/add.ctp
>
> > 
> > create('Download',array('type' => 'file')); ?>
> >    
> >        
> >    
> > echo $this->Form->input('title');
> > echo $form->input('file_name', array('type' => 'file'));
> > $options =
>
> > array('d'=>'Document','P'=>'Pdf','A'=>'Audio','C'=>'Compressed','o'=>'Other');
> > echo $form->select('type',$options,'f',array('empty'=>false));
>
> >    ?>
> >    
> > Form->end(__('Submit', true));?>
> > 
> > 
> >    
> >    
>
> >        Html->link(__('List Files', true),
> > array('action' => 'index'));?>
> >        Html->link(__('Add File', true),
> > array('action' => 'add')); ?> 
> >    
> > 
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread J.
Thanks for the clarification, but still, users aren't allowed to edit
only themeselves with this method.

If I dot this :

$this->Auth->allow('edit');

any user can edit any other user.

 I want them to only edit their own account. If logged user id is 4, I
want him to be only able to edit User account with id 4.

I don't know if I'm clear when explaining this, sorry.

Thanks !


On 15 jan, 21:46, jeremyharris  wrote:
> Your last post says that if the logged in user equals the user id set on
> the model (wherever you set that), to let them have access. This is
> contradictory to what you said: "users can't edit any profiles"
>
> Your isAuthorized action should be really simple then.
>
> public function isAuthorized() {
> // assuming 1 for admin - there are better ways to check this
> if ($this->Auth->user('group_id') === 1) {
> return true; //admin can do anything}
>
> return false; // users can do nothing
>
> }
>
> Then in your beforeFilters for actions that users *can* do:
>
> // in users controller
> public function beforeFilter() {
> $this->Auth->allow('view'); // users can get to the UsersController::view()
> action
> parent::beforeFilter();
>
> }
>
> Allowing the action will tell the Auth component not to check isAuthorized

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


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


Captcha reload problem

2012-01-15 Thread Daniel
I want a link on my user add page to reload a captcha.  This is the
code I have in the add.ctp view file:


Html->image($this->Html-
>url(array('controller'=>'users', 'action'=>'captcha'),
true), array('style'=>'','vspace'=>2)); ?>

Js->link('Can not read this code? Reload.',
'reload_captcha', array('update'=>'captchaID')); ?>

... and in my controller:

function captcha() {
$code = $this->Utils->captcha_code();
$this->Utils->render_captcha($code);
$this->Session->write('captcha_code', $this->hash_captcha($code));
}
function reload_captcha() {
$this->captcha();
}

This reloads the captcha, but the captcha is on its own, not in the
form e.g. I have lost the form, it is not redrawn.  How can I get the
form to remain?

Thanks.

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread jeremyharris
Your last post says that if the logged in user equals the user id set on 
the model (wherever you set that), to let them have access. This is 
contradictory to what you said: "users can't edit any profiles"

Your isAuthorized action should be really simple then.

public function isAuthorized() {
// assuming 1 for admin - there are better ways to check this
if ($this->Auth->user('group_id') === 1) {
return true; //admin can do anything
}
return false; // users can do nothing
}

Then in your beforeFilters for actions that users *can* do:

// in users controller
public function beforeFilter() {
$this->Auth->allow('view'); // users can get to the UsersController::view() 
action
parent::beforeFilter();
}

Allowing the action will tell the Auth component not to check isAuthorized

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


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


How to link multiple records at once using cakephp hasMany?

2012-01-15 Thread mmahgoub
I googled this a lot but nothing seems to be similar to what i am
looking for..

What i am trying to do is to link one record "User" with other
multiple records "Cards" at once using a multiple HTML  list.

Tables are:
users (id, name, username)
cards (id, user_id)

Models:

class User extends AppModel {
   public $name = 'User';
   public $hasMany = array('Card');}

class Card extends AppModel {
   public $name = 'Card';
   public $belongsTo = array('User');}

User edit.ctp view

echo $this->Form->input('id');
echo $this->Form->input('Card', array('multiple'=>true));

How my controller gonna look like? currently it looks like this but
saves nothing but the User record "without the related cards"

if (!empty($this->data)) {
foreach($this->data['User']['Card'] as $key => $item){
$this->data['User']['Card'][$key] =
array('id'=>$item, 'user_id'=>$this->data['User']['id']);
}
if ($this->User->saveAll($this->data)) {
 //$this->User->Card->saveAll($this-
>data);
$this->Session->setFlash(__('The user has been 
saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not 
be saved.
Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->User->read(null, $id);
 $this->set('cards', $this->User->Card-
>find('list'));
}

$this->data contains:

Array
(
[User] => Array
(
[id] => 1
[name] => Superman
[status] => 1
[Card] => Array
(
[0] => Array
(
[id] => 11402130001
[user_id] => 1
)

[1] => Array
(
[id] => 11402130002
[user_id] => 1
)

[2] => Array
(
[id] => 11402130003
[user_id] => 1
)

[3] => Array
(
[id] => 11402130004
[user_id] => 1
)

)

)
)

Thanks

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


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


Re: how to extract filesize from meioupload with understable format ?

2012-01-15 Thread Thiago Belem
You should save the size in bytes and format it to an human readable format
(2 mb) on the view, with a helper.

--
Thiago Belem,
Desenvolvedor WEB

Enviado do meu Android
Em 15/01/2012 14:59, "ahmed fakher"  escreveu:

> i use meioupload behavior to upload files but i cant know how to sive
> filesize with nice format like (2 mb , 10 kb) ..i see this function in
> meioupload but i dont know how to use it
>
>
> /**
> * Convert a size value to bytes. For example: 2 MB to 2097152.
> *
> * @author Vinicius Mendes
> * @return int
> * @param $size String
> */
>function sizeToBytes($size){
>if(is_numeric($size)) return $size;
>if(!preg_match('/^[1-9][0-9]* (kb|mb|gb|tb)$/i', $size)){
>trigger_error('MeioUploadBehavior Error: The max_size
> option format is invalid.', E_USER_ERROR);
>return 0;
>}
>list($size, $unit) = explode(' ',$size);
>if(strtolower($unit) == 'kb') return $size*1024;
>if(strtolower($unit) == 'mb') return $size*1048576;
>if(strtolower($unit) == 'gb') return $size*1073741824;
>if(strtolower($unit) == 'tb') return $size*1099511627776;
>trigger_error('MeioUploadBehavior Error: The max_size unit is
> invalid.', E_USER_ERROR);
>return 0;
>}
>
> to upload new file downloads/add.ctp
>
>
>
> 
> create('Download',array('type' => 'file')); ?>
>
>
>
> echo $this->Form->input('title');
> echo $form->input('file_name', array('type' => 'file'));
> $options =
>
> array('d'=>'Document','P'=>'Pdf','A'=>'Audio','C'=>'Compressed','o'=>'Other');
> echo $form->select('type',$options,'f',array('empty'=>false));
>
>?>
>
> Form->end(__('Submit', true));?>
> 
> 
>
>
>
>Html->link(__('List Files', true),
> array('action' => 'index'));?>
>Html->link(__('Add File', true),
> array('action' => 'add')); ?> 
>
> 
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

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


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


Re: Problem with TinyMCE

2012-01-15 Thread AD7six


On Jan 15, 6:38 am, ali786 <786ali...@gmail.com> wrote:
> hi
> i have a problem with TinyMCE and its not working in my page
> i see "Parse error" in firebug ( Parse error : syntax error,
> unexpected T_CONSTANT_ENCAPSED_STRING  )
> Please Help me :(

Are you using CakePHP?

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


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


Re: Missing GROUP BY in query SELECT Max(Alias.field1) as field1, field2 From table

2012-01-15 Thread AD7six


On Jan 15, 12:29 pm, quentin  wrote:
> Hi
>
> I have some strange mysql error when I try to select Max(field1) and
> field2. if I select only Max(field1) ( SELECT Max(Alias.field1) as field1
> From table ) it works.
> Ok this error probably comes from the mysql version ( ovh server : mysql
> client Api Version 5.0.32 ) because everything works with all my other
> configuration.
>
> *This error is easy to fix* : I add 'group'=>array('Alias.primaryKey') in
> the options of the find function.
> but the TreeBehavior for example frequently ask for the Max(Tree.rght) with

The key for you to understand your question is to realize it's 100%
sql.

select max(foo) from bar

is the same as

select foo from bar order by foo DESC LIMIT 1

The tree behavior does not mix max() with other fields - if you are
doing that it's something related to how you've configured/setup
$recursive and other associations in your model.

> other fields (during Insertion for example) and doesn't group rows.
>
> So when I create Menu (using Tree behavior) I have a mysql error.

The tree behavior is not required to build a menu, I would say it's
inappropriate to use the tree behavior for _just_ a menu.

AD

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


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


Re: Authentication Application Tutorial help. Login just reloads login page.

2012-01-15 Thread Jeremy Harris
When you omit the "controller" key it points to the current controller. So
if you were missing a view method on that controller you'd get an error.

Anyway if the tutorial is wrong the core team would love a contribution :)

-Jeremy
On Jan 15, 2012 6:06 AM, "Ella Källman"  wrote:

> Thanks! It works now, I redid the tutorial for the third time and now
> it works. I really don't know what I did differently, but at least now
> it works. :)
>
> I will look into DebugKit, sounds great.
>
> One thing I noticed is that you have to change all $this-
> >redirect(array('action' => 'index')); lines to $this-
> >redirect(array('controller' => 'posts', 'action' => 'index')); if you
> are using code from the blog tutorial as the foundation for this
> tutorial. I got a lot of missing view errors before I changed this. It
> would have been great if you were told to change this in the tutorial.
> The loginRedirect and logoutRedirect are correct in the tutorial, but
> not the redirects in the add, edit and delete functions in the
> UsersController.
> I think a lot of people uses these two tutorials to get to know
> CakePHP, so this is something I really think should be added to the
> Authentication Application Tutorial.
>
> On 15 Jan, 02:10, jeremyharris  wrote:
> > You may not be getting auth flash messages if you don't have the
> following
> > bit in your layout:
> >
> > echo $this->Session->flash('auth');
> >
> > That will give you a hint as to what's going on. Or, check your session
> > vars (use DebugKit - it's a massive time save).
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php
>

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


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


Re: Digest for cake-php@googlegroups.com - 24 Messages in 11 Topics

2012-01-15 Thread AD7six


On Jan 15, 11:38 am, Nasir Ali  wrote:
> Can anybody tell me how to configure cakephp to window 7? OR refer me to
> any useful link?

What have you tried so far?

AD

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


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


Missing GROUP BY in query SELECT Max(Alias.field1) as field1, field2 From table

2012-01-15 Thread quentin
Hi

I have some strange mysql error when I try to select Max(field1) and 
field2. if I select only Max(field1) ( SELECT Max(Alias.field1) as field1 
>From table ) it works.
Ok this error probably comes from the mysql version ( ovh server : mysql 
client Api Version 5.0.32 ) because everything works with all my other 
configuration.

*This error is easy to fix* : I add 'group'=>array('Alias.primaryKey') in 
the options of the find function.
but the TreeBehavior for example frequently ask for the Max(Tree.rght) with 
other fields (during Insertion for example) and doesn't group rows.

So when I create Menu (using Tree behavior) I have a mysql error.

*Is it a cakePhp bug or is there a way to make it works?* (currently I've 
added 'group' option to the TreeBehavior::_getMax(...) function )

Thanks for reading me (and my poor english) and for all the great work 
you're doing!!

Quentin

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


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


Problem with TinyMCE

2012-01-15 Thread ali786
hi
i have a problem with TinyMCE and its not working in my page
i see "Parse error" in firebug ( Parse error : syntax error,
unexpected T_CONSTANT_ENCAPSED_STRING  )
Please Help me :(

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


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


Problem with TinyMCE

2012-01-15 Thread ali786
hi
i have a problem with TinyMCE and its not working in my page
i see "Parse error" in firebug ( Parse error : syntax error,
unexpected T_CONSTANT_ENCAPSED_STRING  )
Please Help me :(

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


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


how to extract filesize from meioupload with understable format ?

2012-01-15 Thread ahmed fakher
i use meioupload behavior to upload files but i cant know how to sive
filesize with nice format like (2 mb , 10 kb) ..i see this function in
meioupload but i dont know how to use it


/**
 * Convert a size value to bytes. For example: 2 MB to 2097152.
 *
 * @author Vinicius Mendes
 * @return int
 * @param $size String
 */
function sizeToBytes($size){
if(is_numeric($size)) return $size;
if(!preg_match('/^[1-9][0-9]* (kb|mb|gb|tb)$/i', $size)){
trigger_error('MeioUploadBehavior Error: The max_size
option format is invalid.', E_USER_ERROR);
return 0;
}
list($size, $unit) = explode(' ',$size);
if(strtolower($unit) == 'kb') return $size*1024;
if(strtolower($unit) == 'mb') return $size*1048576;
if(strtolower($unit) == 'gb') return $size*1073741824;
if(strtolower($unit) == 'tb') return $size*1099511627776;
trigger_error('MeioUploadBehavior Error: The max_size unit is
invalid.', E_USER_ERROR);
return 0;
}

to upload new file downloads/add.ctp




create('Download',array('type' => 'file')); ?>


Form->input('title');
echo $form->input('file_name', array('type' => 'file'));
$options =
array('d'=>'Document','P'=>'Pdf','A'=>'Audio','C'=>'Compressed','o'=>'Other');
echo $form->select('type',$options,'f',array('empty'=>false));

?>

Form->end(__('Submit', true));?>





Html->link(__('List Files', true),
array('action' => 'index'));?>
Html->link(__('Add File', true),
array('action' => 'add')); ?> 



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


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


Re: Captcha image won't display

2012-01-15 Thread Daniel
I found the answer was that the Auth component was blocking the
action.  When I added 'capcha' to the Auth allow list it worked.

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


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


Re: Captcha image won't display

2012-01-15 Thread Daniel
I made a bare minimum set up which fails to draw any image.  The view
is only:

Html->image($this->Html-
>url(array('controller'=>'users', 'action'=>'captcha'),
true), array('style'=>'','vspace'=>2)); ?>

and the controller function is:
function captcha()  {
$this->autoRender = false;
header('Content-Type: image/png');
$x1 = 199;
$y1 = 63;
$im = imagecreatetruecolor($x1 + 1, $y1 + 1);
$bkcol = imagecolorallocate($im, 128, 128, 128);
imagefilledrectangle($im, 0, 0, $x1, $y1, $bkcol);
imagepng($im);
imagedestroy($im);
}

... that is it.  As before this fails with no error message, the image
is just a small red cross instead of a grey box.

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread J.
This does'nt work too:

public function isAuthorized($user) {
if (parent::isAuthorized($user)) {
return true;
}

if ($this->action === 'edit') {
if ($this->Auth->user('id') == $this->User->id) {
 return true;
}
}

return false;
}

On 15 jan, 16:26, "J."  wrote:
> I tried everything and I still don't understand why this isn't working
> in my UsersController :
>
> public function isAuthorized($user) {
>         if (parent::isAuthorized($user)) {
>             return true;
>         }
>
>         if (($this->action === 'edit') && ($this->User->id === 
> $this->Auth->user('id'))) {
>
>             return true;
>         }
>
>         return false;
>     }
>
> Any idea ? Thanks a lot.
>
> On 15 jan, 11:43, "J."  wrote:
>
>
>
>
>
>
>
> > Ok, I modified the UsersController like this :
>
> >     public function isAuthorized($user) {
> >         if (parent::isAuthorized($user)) {
> >             return true;
> >         }
>
> >         if (in_array($this->action, array('edit', 'delete'))) {
> >             if ($this->User->id == $this->Session->read('Auth.User.id')) {
>
> >                 return true;
> >                 }
> >         }
>
> >         return false;
> >     }
>
> > , I don't get the notice anymore, BUT USers still can edit
> > themeselves: any try for editing will redirect to the index. So :
> > Admin can edit any one, users can't edit any profiles. I just need to
> > find out how to allow them editing their own.
>
> > I thought thi woul check if the user ID was the same as the id stored
> > when logged :
>
> > if ($this->User->id == $this->Session->read('Auth.User.id')) {
> >                 return true;
> >                 }
>
> > but it doesn't seem to work.
>
> > Any help ? Thanks a lot.
>
> > On 15 jan, 11:38, "J."  wrote:
>
> > > I think I'm near the solution, but I need help for finishing the
> > > code :
>
> > > Here is my app controller :
>
> > >     public function isAuthorized($user) {
> > >         if (isset($user['role']) && $user['role'] === 'admin') {
> > >             return true; //Admin can access every action
> > >         }
> > >         return false; // The rest don't
> > >     }
>
> > >     function beforeFilter() {
> > >         $this->Auth->allow('index', 'view');
> > >         $this->Auth->allow('display');
> > >     }
>
> > > And my UsersController :
>
> > >   public function isAuthorized($user) {
> > >         if (parent::isAuthorized($user)) {
> > >             return true;
> > >         }
>
> > >         if (in_array($this->action, array('edit', 'delete'))) {
> > >             if ($user['User']['id'] == 
> > > $this->Session->read('Auth.User.id')) {
>
> > >             return true;
> > >                 }
> > >         }
>
> > >         return false;
> > >     }
>
> > > With this code, Admin can edit everyone, but when a logge duser tries
> > > to edit himself, I get this notice :
>
> > > Notice (8): Undefined index:  User [APP/Controller/
> > > UsersController.php, line 60]
> > > Code Context
>
> > >         if (in_array($this->action, array('edit', 'delete'))) {
> > >             if ($user['User']['id'] == 
> > > $this->Session->read('Auth.User.id')) {
>
> > > UsersController::isAuthorized() - APP/Controller/UsersController.php,
> > > line 60
> > > ControllerAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/
> > > ControllerAuthorize.php, line 64
> > > AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/
> > > AuthComponent.php, line 379
> > > AuthComponent::startup() - CORE/Cake/Controller/Component/
> > > AuthComponent.php, line 330
> > > ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php,
> > > line 103
> > > Controller::startupProcess() - CORE/Cake/Controller/Controller.php,
> > > line 606
> > > Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 104
> > > Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
> > > [main] - APP/webroot/index.php, line 96
>
> > > Any idea what I should add next ? Perhaps in my User Model ? Many
> > > thanks !
>
> > > On 14 jan, 19:44, Salines  wrote:
>
> > > > I think you have answer in one of this videos
>
> > > >http://www.youtube.com/results?search_query=cakephp+auth

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread J.
I tried everything and I still don't understand why this isn't working
in my UsersController :

public function isAuthorized($user) {
if (parent::isAuthorized($user)) {
return true;
}

if (($this->action === 'edit') && ($this->User->id === $this-
>Auth->user('id'))) {
return true;
}

return false;
}

Any idea ? Thanks a lot.


On 15 jan, 11:43, "J."  wrote:
> Ok, I modified the UsersController like this :
>
>     public function isAuthorized($user) {
>         if (parent::isAuthorized($user)) {
>             return true;
>         }
>
>         if (in_array($this->action, array('edit', 'delete'))) {
>             if ($this->User->id == $this->Session->read('Auth.User.id')) {
>
>                 return true;
>                 }
>         }
>
>         return false;
>     }
>
> , I don't get the notice anymore, BUT USers still can edit
> themeselves: any try for editing will redirect to the index. So :
> Admin can edit any one, users can't edit any profiles. I just need to
> find out how to allow them editing their own.
>
> I thought thi woul check if the user ID was the same as the id stored
> when logged :
>
> if ($this->User->id == $this->Session->read('Auth.User.id')) {
>                 return true;
>                 }
>
> but it doesn't seem to work.
>
> Any help ? Thanks a lot.
>
> On 15 jan, 11:38, "J."  wrote:
>
>
>
>
>
>
>
> > I think I'm near the solution, but I need help for finishing the
> > code :
>
> > Here is my app controller :
>
> >     public function isAuthorized($user) {
> >         if (isset($user['role']) && $user['role'] === 'admin') {
> >             return true; //Admin can access every action
> >         }
> >         return false; // The rest don't
> >     }
>
> >     function beforeFilter() {
> >         $this->Auth->allow('index', 'view');
> >         $this->Auth->allow('display');
> >     }
>
> > And my UsersController :
>
> >   public function isAuthorized($user) {
> >         if (parent::isAuthorized($user)) {
> >             return true;
> >         }
>
> >         if (in_array($this->action, array('edit', 'delete'))) {
> >             if ($user['User']['id'] == 
> > $this->Session->read('Auth.User.id')) {
>
> >             return true;
> >                 }
> >         }
>
> >         return false;
> >     }
>
> > With this code, Admin can edit everyone, but when a logge duser tries
> > to edit himself, I get this notice :
>
> > Notice (8): Undefined index:  User [APP/Controller/
> > UsersController.php, line 60]
> > Code Context
>
> >         if (in_array($this->action, array('edit', 'delete'))) {
> >             if ($user['User']['id'] == 
> > $this->Session->read('Auth.User.id')) {
>
> > UsersController::isAuthorized() - APP/Controller/UsersController.php,
> > line 60
> > ControllerAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/
> > ControllerAuthorize.php, line 64
> > AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/
> > AuthComponent.php, line 379
> > AuthComponent::startup() - CORE/Cake/Controller/Component/
> > AuthComponent.php, line 330
> > ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php,
> > line 103
> > Controller::startupProcess() - CORE/Cake/Controller/Controller.php,
> > line 606
> > Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 104
> > Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
> > [main] - APP/webroot/index.php, line 96
>
> > Any idea what I should add next ? Perhaps in my User Model ? Many
> > thanks !
>
> > On 14 jan, 19:44, Salines  wrote:
>
> > > I think you have answer in one of this videos
>
> > >http://www.youtube.com/results?search_query=cakephp+auth

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


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


Re: Authentication Application Tutorial help. Login just reloads login page.

2012-01-15 Thread Ella Källman
Thanks! It works now, I redid the tutorial for the third time and now
it works. I really don't know what I did differently, but at least now
it works. :)

I will look into DebugKit, sounds great.

One thing I noticed is that you have to change all $this-
>redirect(array('action' => 'index')); lines to $this-
>redirect(array('controller' => 'posts', 'action' => 'index')); if you
are using code from the blog tutorial as the foundation for this
tutorial. I got a lot of missing view errors before I changed this. It
would have been great if you were told to change this in the tutorial.
The loginRedirect and logoutRedirect are correct in the tutorial, but
not the redirects in the add, edit and delete functions in the
UsersController.
I think a lot of people uses these two tutorials to get to know
CakePHP, so this is something I really think should be added to the
Authentication Application Tutorial.

On 15 Jan, 02:10, jeremyharris  wrote:
> You may not be getting auth flash messages if you don't have the following
> bit in your layout:
>
> echo $this->Session->flash('auth');
>
> That will give you a hint as to what's going on. Or, check your session
> vars (use DebugKit - it's a massive time save).

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


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


Re: Need cakePHP project

2012-01-15 Thread gimmebucks
Can i see your sample works(portfolio).

On Jan 14, 1:03 pm, Hung  wrote:
> Hi everyone !
>
> I am Hung in Viet Nam,  I have strong experience with cakePHP and now
> i am looking for some project for my team to work on, if you guys have
> project pls contact me.
>
> Thanks

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread J.
Ok, I modified the UsersController like this :

public function isAuthorized($user) {
if (parent::isAuthorized($user)) {
return true;
}

if (in_array($this->action, array('edit', 'delete'))) {
if ($this->User->id == $this->Session-
>read('Auth.User.id')) {
return true;
}
}

return false;
}

, I don't get the notice anymore, BUT USers still can edit
themeselves: any try for editing will redirect to the index. So :
Admin can edit any one, users can't edit any profiles. I just need to
find out how to allow them editing their own.

I thought thi woul check if the user ID was the same as the id stored
when logged :

if ($this->User->id == $this->Session->read('Auth.User.id')) {
return true;
}

but it doesn't seem to work.

Any help ? Thanks a lot.

On 15 jan, 11:38, "J."  wrote:
> I think I'm near the solution, but I need help for finishing the
> code :
>
> Here is my app controller :
>
>     public function isAuthorized($user) {
>         if (isset($user['role']) && $user['role'] === 'admin') {
>             return true; //Admin can access every action
>         }
>         return false; // The rest don't
>     }
>
>     function beforeFilter() {
>         $this->Auth->allow('index', 'view');
>         $this->Auth->allow('display');
>     }
>
> And my UsersController :
>
>   public function isAuthorized($user) {
>         if (parent::isAuthorized($user)) {
>             return true;
>         }
>
>         if (in_array($this->action, array('edit', 'delete'))) {
>             if ($user['User']['id'] == $this->Session->read('Auth.User.id')) {
>
>             return true;
>                 }
>         }
>
>         return false;
>     }
>
> With this code, Admin can edit everyone, but when a logge duser tries
> to edit himself, I get this notice :
>
> Notice (8): Undefined index:  User [APP/Controller/
> UsersController.php, line 60]
> Code Context
>
>         if (in_array($this->action, array('edit', 'delete'))) {
>             if ($user['User']['id'] == $this->Session->read('Auth.User.id')) {
>
> UsersController::isAuthorized() - APP/Controller/UsersController.php,
> line 60
> ControllerAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/
> ControllerAuthorize.php, line 64
> AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/
> AuthComponent.php, line 379
> AuthComponent::startup() - CORE/Cake/Controller/Component/
> AuthComponent.php, line 330
> ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php,
> line 103
> Controller::startupProcess() - CORE/Cake/Controller/Controller.php,
> line 606
> Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 104
> Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
> [main] - APP/webroot/index.php, line 96
>
> Any idea what I should add next ? Perhaps in my User Model ? Many
> thanks !
>
> On 14 jan, 19:44, Salines  wrote:
>
>
>
>
>
>
>
> > I think you have answer in one of this videos
>
> >http://www.youtube.com/results?search_query=cakephp+auth

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


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


Re: Users can only edit or delete themselves

2012-01-15 Thread J.
I think I'm near the solution, but I need help for finishing the
code :

Here is my app controller :

public function isAuthorized($user) {
if (isset($user['role']) && $user['role'] === 'admin') {
return true; //Admin can access every action
}
return false; // The rest don't
}


function beforeFilter() {
$this->Auth->allow('index', 'view');
$this->Auth->allow('display');
}


And my UsersController :

  public function isAuthorized($user) {
if (parent::isAuthorized($user)) {
return true;
}

if (in_array($this->action, array('edit', 'delete'))) {
if ($user['User']['id'] == $this->Session-
>read('Auth.User.id')) {
return true;
}
}

return false;
}


With this code, Admin can edit everyone, but when a logge duser tries
to edit himself, I get this notice :


Notice (8): Undefined index:  User [APP/Controller/
UsersController.php, line 60]
Code Context

if (in_array($this->action, array('edit', 'delete'))) {
if ($user['User']['id'] == $this->Session-
>read('Auth.User.id')) {
UsersController::isAuthorized() - APP/Controller/UsersController.php,
line 60
ControllerAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/
ControllerAuthorize.php, line 64
AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/
AuthComponent.php, line 379
AuthComponent::startup() - CORE/Cake/Controller/Component/
AuthComponent.php, line 330
ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php,
line 103
Controller::startupProcess() - CORE/Cake/Controller/Controller.php,
line 606
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 104
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
[main] - APP/webroot/index.php, line 96


Any idea what I should add next ? Perhaps in my User Model ? Many
thanks !



On 14 jan, 19:44, Salines  wrote:
> I think you have answer in one of this videos
>
> http://www.youtube.com/results?search_query=cakephp+auth

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


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