Acl using PhpAcl problem

2014-12-16 Thread Oka Prinarjaya
Hello Folks :)

Please help me, I have a problem with CakePHP ACL using class PhpAcl. 

This is my Auth component setup in AppController

?php
class AppController extends Controller {

public $components = array(
'Acl',
'Auth' = array(
'authorize' = array('Actions' = array('actionPath' = 
'controllers/')),
'unauthorizedRedirect' = array(
'plugin' = null,
'controller' = 'dashboard',
'action' = 'index'
),
'autoRedirect' = false
),
'Session'
);

this is my setup in acl.php

?php
$config['map'] = array(
'User' = 'User/email',
'Role' = 'User/role', // -- field 'role' in my users table
);

/**
 * role configuration
 */
$config['roles'] = array(
'Role/admin' = null,
'Role/entry' = null
);

/**
 * rule configuration
 */
$config['rules'] = array(
'allow' = array(
'*' = 'Role/admin',
'controllers/crm_customers/*' = 'Role/entry',
'controllers/dashboard/index' = 'Role/entry'
),
'deny' = array()
);

The problem is, Role/entry can never access crm_customers controller and 
its methods , 
BUT Role/admin no problem. Role/admin can access all controllers and its 
methods. 

I also try to set only spesific method name on a controller:
$config['rules'] = array(
'allow' = array(
'*' = 'Role/admin',
'controllers/crm_customers/index' = 'Role/entry',
'controllers/crm_customers/add' = 'Role/entry',
'controllers/crm_customers/edit' = 'Role/entry',
'controllers/dashboard/index' = 'Role/entry'
),
'deny' = array()
);

but still can never access what have been defined :( 

Please help me, 


Thank You :)

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: cakephp 3.0 save new entity with new related data

2014-12-16 Thread José Lorenzo
_ids only works with sending existing ids, you will need to send data 
formatted correctly so the marshaller creates entities of the desired type. 
Similar to what you would do for creating belongsTo or hasMany associations.

On Monday, December 15, 2014 7:13:35 PM UTC+1, Radharadhya Dasa wrote:

 Hi,

 I want to save a new contact. The contacts has skills (belongsToMany). 
 Skill is a text input and with jquery autocomplete I search for existing 
 skills. If the user select existing skills their id is sent to to 
 controller, if they create new skills the controller gets their names 
 starting with a ~ char.

 So my controller gets something like this: 
 /*debug($this-request-data);
   'name' = 'John Doe',
   'email' = 'j...@nowhere.com',
   'skills' = [
 '_ids' = [
   (int) 0 = '1',//found in skills, this is the id
   (int) 1 = '~könyvelő' //starts with ~ this is a new skill (or 
 fast typer problem)
 ]
   ]
 */


 If I have no new skill (a skill what starts with ~) I can do the 
 following:

 $contact = $this-Contacts-newEntity($this-request-data);
 this-Contacts-save($contact);

 But if I have new skill I should save it first, get the corresponding id, 
 replace the name with the id and than I could save it. Is it the way? I did 
 not find any way to get the last inserted id.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Save not escape only field CakePHP 2

2014-12-16 Thread Rafael Queiroz
It's a requirement for project, i have no details, just save and deliver
data.
Thanks John.

On Mon, Dec 15, 2014 at 4:39 PM, John Andersen j.andersen...@gmail.com
wrote:

 Hi Rafael

 According to the CakePHP book 2.x, then CakePHP automatically escapes the
 Model::save and the Model::find methods, so that your data will be escaped
 and saved in the database, but will be un-escaped when you read it back
 again.

 Near this location in the CakePHP book:

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions

 There was no mention of a possibility to turn it off, but it did mention
 that you could use Model::query instead, although not recommended as it
 gives the possibility for SQL injection to happen.

 Near this location in the CakePHP book:
 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query

 Why do you need the content to be non-escaped in the database?
 Enjoy, John


 On Monday, 15 December 2014 15:11:50 UTC+2, Rafael Queiroz wrote:

 Hi guys,

 I mockup this data for save:

 'Banner' = array(
 'title' = 'Test',
 'link' = 'test',
 'content' = 'div class=banner-content
 div class=container
 figure
 img src=img/banner/desconto-10-novo.jpg
 width=1000 height=292 alt=
 /figure
 /div
 /div',
 'start' = '2014-12-15',
 'expires' = '',
 'position' = '1',
 'active' = '1'
 )

 My problem happens after save, the content field in database:

 'div class=\banner-content\\ndiv
 class=\container\\nfigure\n
 img src=\img/banner/desconto-10-novo.jpg\
 width=\1000\ height=\292\ alt=\\\n
 /figure\n/div\n/div'

 I don't want  escape only content field, i want save equal (===) to
 mockup data, any solutions? Thanks.


 --
 Regards,

 Rafael F. Queiroz

  --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.



-- 
Atenciosamente,

Rafael F. Queiroz

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Save not escape only field CakePHP 2

2014-12-16 Thread euromark
Actually, the save() etc don't modify your data.
They simply store it the same way you give it to them.
It might only be displayed this way in your sql backend.


Am Dienstag, 16. Dezember 2014 11:44:08 UTC+1 schrieb Rafael Queiroz:

 It's a requirement for project, i have no details, just save and deliver 
 data.
 Thanks John.

 On Mon, Dec 15, 2014 at 4:39 PM, John Andersen j.ande...@gmail.com 
 javascript: wrote:

 Hi Rafael

 According to the CakePHP book 2.x, then CakePHP automatically escapes the 
 Model::save and the Model::find methods, so that your data will be escaped 
 and saved in the database, but will be un-escaped when you read it back 
 again.

 Near this location in the CakePHP book:

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions

 There was no mention of a possibility to turn it off, but it did mention 
 that you could use Model::query instead, although not recommended as it 
 gives the possibility for SQL injection to happen.

 Near this location in the CakePHP book:

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query

 Why do you need the content to be non-escaped in the database?
 Enjoy, John


 On Monday, 15 December 2014 15:11:50 UTC+2, Rafael Queiroz wrote:

 Hi guys,

 I mockup this data for save:

 'Banner' = array(
 'title' = 'Test',
 'link' = 'test',
 'content' = 'div class=banner-content
 div class=container
 figure
 img src=img/banner/desconto-10-novo.jpg 
 width=1000 height=292 alt=
 /figure
 /div
 /div',
 'start' = '2014-12-15',
 'expires' = '',
 'position' = '1',
 'active' = '1'
 )

 My problem happens after save, the content field in database:

 'div class=\banner-content\\ndiv 
 class=\container\\nfigure\n
 img src=\img/banner/desconto-10-novo.jpg\ 
 width=\1000\ height=\292\ alt=\\\n
 /figure\n/div\n/div'

 I don't want  escape only content field, i want save equal (===) to 
 mockup data, any solutions? Thanks.


 -- 
 Regards,

 Rafael F. Queiroz
  
  -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to cake-php+u...@googlegroups.com javascript:.
 To post to this group, send email to cake...@googlegroups.com 
 javascript:.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.



 -- 
 Atenciosamente,

 Rafael F. Queiroz
  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: 3.0 using FormHelper inside MyHtmlHelper

2014-12-16 Thread euromark
See that one?
https://github.com/cakephp/cakephp/blob/3.0/src/View/Helper/HtmlHelper.php#L39

It's dangerous to overwrite a core helper and remove functionality from it.

So you should either not overwrite $helpers, or do it correcty. Meaning, 
appending to it while not removing anything:

public $helpers = ['Url', 'Form']; 


mark


Am Sonntag, 14. Dezember 2014 05:32:59 UTC+1 schrieb Ahmad baiquni habibi:

 hi, I try to do 
 http://book.cakephp.org/3.0/en/views/helpers.html#including-other-helpers 
 into MyHtmlHelper, but get error. Please help how to do it properly?

 here my code:
 ?php
 namespace App\View\Helper;
 use Cake\View\Helper\HtmlHelper;

 class MyHtmlHelper extends HtmlHelper {
  
 
 public $helpers = ['Form']; 
 /*
 Fatal Error
 Error: Call to a member function build() on a non-object
 File 
 E:\xampp\htdocs\portfolio\hrd\vendor\cakephp\cakephp\src\View\Helper\HtmlHelper.php
 Line: 323
 */
 
 public function edit($id = null){
 
 $title = 'edit';
 $url = ['action'='edit', $id];
 return $this-link($title, $url, $options = array());
 
 }
 
 public function hapus($id = null){
 $title = 'hapus';
 $url = ['action'='delete', $id];
 $options['confirm'] = 'yakin menghapus?'; 
 
 return $this-Form-postLink($title, $url , $options);
 
 }
 
 }





-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: cakephp 3.0 save new entity with new related data

2014-12-16 Thread Radharadhya Dasa
As marshaller accepts existing related data OR new related data, but NOT 
both I had do like this.

$contact = $this-Contacts-newEntity($this-request-data);
if($this-request-data){
//debug($this-request-data);
/*'skills' = [
'_ids' = [
(int) 0 = '1',//found in skills, this is the id
(int) 1 = '~könyvelő'//starts with ~ this is a new 
skill (or fast typer problem)
]]
*/
foreach($this-request-data['skills']['_ids'] as $i = $skill){
if(mb_substr($skill, 0,1) == '~'){
$skill = ltrim($skill, '~');
$contact['skills'][] = $this-Contacts-Skills-newEntity([
'name' = $skill]);
}
}
}

And now it works like a charm. :)

CakePHP is great :)

2014. december 16., kedd 9:40:22 UTC+1 időpontban José Lorenzo a következőt 
írta:

 _ids only works with sending existing ids, you will need to send data 
 formatted correctly so the marshaller creates entities of the desired type. 
 Similar to what you would do for creating belongsTo or hasMany associations.

 On Monday, December 15, 2014 7:13:35 PM UTC+1, Radharadhya Dasa wrote:

 Hi,

 I want to save a new contact. The contacts has skills (belongsToMany). 
 Skill is a text input and with jquery autocomplete I search for existing 
 skills. If the user select existing skills their id is sent to to 
 controller, if they create new skills the controller gets their names 
 starting with a ~ char.

 So my controller gets something like this: 
 /*debug($this-request-data);
   'name' = 'John Doe',
   'email' = 'j...@nowhere.com javascript:',
   'skills' = [
 '_ids' = [
   (int) 0 = '1',//found in skills, this is the id
   (int) 1 = '~könyvelő' //starts with ~ this is a new skill 
 (or fast typer problem)
 ]
   ]
 */


 If I have no new skill (a skill what starts with ~) I can do the 
 following:

 $contact = $this-Contacts-newEntity($this-request-data);
 this-Contacts-save($contact);

 But if I have new skill I should save it first, get the corresponding id, 
 replace the name with the id and than I could save it. Is it the way? I did 
 not find any way to get the last inserted id.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Save not escape only field CakePHP 2

2014-12-16 Thread John Andersen
Hi Euromark

Actually CakePHP 2.x does modify the data - it escapes and quotes the data 
during the save - using the DboSource method value() - found here:
http://api.cakephp.org/2.5/class-DboSource.html#_value

Called by the DboSource method create() - found here:
http://api.cakephp.org/2.5/source-class-DboSource.html#974-1021

Enjoy, John

On Tuesday, 16 December 2014 16:56:58 UTC+2, euromark wrote:

 Actually, the save() etc don't modify your data.
 They simply store it the same way you give it to them.
 It might only be displayed this way in your sql backend.

 [snip]


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.