Prefixing site url with username

2011-03-26 Thread hunny
Hi,

I want to prefix my site url, say www.example.com, with the username,
say user1, so that the url looks like www.user1.example.com.
Any ideas on how to achieve this.

Also wondering if I will need to change HTML Helper so that all the
links are prefixed with username.

Thanx in Advance,
Hunny.

-- 
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 hide rewrite url in cakephp?

2011-03-26 Thread push
Hi all,

I am doing web application, I want hide my url for security purpose.
My home page url is www.mydomine.com/cakephp. I want my home page url
to be www.mydomine.com , Please tell me how to hide cakephp?



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


CakeDC Comments Plugin

2011-03-26 Thread Meroe Meroe
Hello all,

I'm using the cakedc comments plugin.  I have it working on the view
actions, but according to the notes I should be able to provide actionNames
and override the default action the comments appear on.  In my case I want
the comments to appear on the supervisor action.  I've done everything I
can think of to get this to work, but it continues to ONLY work on the view
action.

Thoughts?

https://github.com/CakeDC/comments/tree/develop

comment_action - this parameter used, to pass what action should performed

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


extends autoComplete - Need ID of chosen element and set it inside hidden field

2011-03-26 Thread Mariano C.
I followed http://book.cakephp.org/view/632/autoComplete, and this
work. Now the problem is:
I choose an element from suggested items, but actually I haven't ID so
this isn't so usefull.
It could be better if as soon I choose an element, it's id will be
stored immediatly inside an hidden input, so I could send it to the
form's action with proper info.

How can I do that?

-- 
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 hide rewrite url in cakephp?

2011-03-26 Thread Ryan Schmidt

On Mar 26, 2011, at 00:51, push wrote:

 I am doing web application, I want hide my url for security purpose.
 My home page url is www.mydomine.com/cakephp. I want my home page url
 to be www.mydomine.com , Please tell me how to hide cakephp?

Set up your DocumentRoot properly in your Apache configuration.


-- 
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: Prefixing site url with username

2011-03-26 Thread Ryan Schmidt

On Mar 26, 2011, at 04:15, hunny wrote:

 I want to prefix my site url, say www.example.com, with the username,
 say user1, so that the url looks like www.user1.example.com.
 Any ideas on how to achieve this.

First you'd need to set up your VirtualHost directive in Apache with a 
ServerAlias directive that matches every possible hostname you want it to 
serve, like

ServerAlias *.example.com

or maybe

ServerAlias www.*.example.com

(not sure if that last one works)

Then you'll need to program your CakePHP app to recognize the hostname in the 
HTTP request and do something (whatever you're wanting to do) with the username 
part.

 Also wondering if I will need to change HTML Helper so that all the
 links are prefixed with username.

The links your app generates would only need to include the protocol and 
hostname if the hostname changes. Otherwise the existing helper method is fine.



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


validate unique on batch imports

2011-03-26 Thread euromark
I encountered this problem several times with some batch imports or
multiple form boxes saved together.

You have a validation rule isUnique for the title.
If you validate all your - lets say 15 - records, they are OK, even if
two of them have the same name.
Thats because the validation can only compare the 15 records to the
current db content, not to each other.

In some cases you could probably just compare the new values and find
out if there are more than 2 of the same title.
But with some beforeValidation or beforeSave or even behaviors this is
not as easy anymore.

Did anyone find a solution to this problem?
I was thinking:
Creating virtual records in a special isUnique validation rule and
not only checking on isUnique in the DB but also comparing the value
to all the previously checked ones.

If you don't do it this way, some of your records will just be omitted
because the validation fails for them, although saveAll() with
validate=first returned true in the first place...

-- 
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: validate unique on batch imports

2011-03-26 Thread cricket
On Sat, Mar 26, 2011 at 7:40 PM, euromark dereurom...@googlemail.com wrote:
 I encountered this problem several times with some batch imports or
 multiple form boxes saved together.

 You have a validation rule isUnique for the title.
 If you validate all your - lets say 15 - records, they are OK, even if
 two of them have the same name.
 Thats because the validation can only compare the 15 records to the
 current db content, not to each other.

 In some cases you could probably just compare the new values and find
 out if there are more than 2 of the same title.
 But with some beforeValidation or beforeSave or even behaviors this is
 not as easy anymore.

 Did anyone find a solution to this problem?
 I was thinking:
 Creating virtual records in a special isUnique validation rule and
 not only checking on isUnique in the DB but also comparing the value
 to all the previously checked ones.

 If you don't do it this way, some of your records will just be omitted
 because the validation fails for them, although saveAll() with
 validate=first returned true in the first place...

Yes, beforeSave() wouldn't help because it's called for each individual record.

How about something like this in AppModel?

function saveAll($data = null, $options = array())
{
if (isset($options)  is_array($options) 
isset($options['validate'])  $options['validate'] !== false)
{
foreach($this-validate as $key = $rule_set)
{
if (isset($rule_set['rule'])  'isUnique' == 
$rule_set['rule'])
{
$records = Set::extract(
$this-alias.'/'.$key,
$data
);

if (sizeof($records)  array_unique($records))
{
$this-validationErrors[$key] = 
'non-unique values';
}
}
}

if (sizeof($this-validationErrors))
{
return false;
}
}
return parent::saveAll($data, $options);
}

Completely untested. And I'm sure it could use some tightening up.

-- 
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: validate unique on batch imports

2011-03-26 Thread euromark
just wrote something myself - although its not tested yet, either:

/**
 * @param array $data
 * @param array $options
 * - scope (array of other fields as scope - isUnique dependent on
other fields of the table)
 * - batch (defaults to true, remembers previous values in order to
validate batch imports)
 * example in model: 'rule' = array ('validateUniqueExt',
array('scope'=array('belongs_to_table_id', 'user_id'))),
 * //TODO: test!!!
 * 2011-03-27 ms
 */
function validateUniqueExt($data, $options = array()) {
foreach ($data as $key = $value) {
$fieldName = $key;
$fieldValue = $value;
}
$defaults = array('batch'=true, 'scope'=array());
$options = array_merge($defaults, $options);

# for batch
if ($options['batch'] !== false  !empty($this-batchRecords)) 
{
if (array_key_exists($value,
$this-batchRecords[$fieldName])) {
return $options['scope'] === 
$this-batchRecords[$fieldName]
[$value];
}
}

# continue with validation
if (!$this-validateUnique($data, $options['scope'])) {
return false;
}

# for batch
if ($options['batch'] !== false) {
if (!isset($this-batchRecords)) {
$this-batchRecords = array();
}
$this-batchRecords[$fieldName][$value] = $scope;
}
return true;
}

this way it doesnt matter if its called from saveAll() or multiple
validates()


On 27 Mrz., 01:47, cricket zijn.digi...@gmail.com wrote:
 On Sat, Mar 26, 2011 at 7:40 PM, euromark dereurom...@googlemail.com wrote:
  I encountered this problem several times with some batch imports or
  multiple form boxes saved together.

  You have a validation rule isUnique for the title.
  If you validate all your - lets say 15 - records, they are OK, even if
  two of them have the same name.
  Thats because the validation can only compare the 15 records to the
  current db content, not to each other.

  In some cases you could probably just compare the new values and find
  out if there are more than 2 of the same title.
  But with some beforeValidation or beforeSave or even behaviors this is
  not as easy anymore.

  Did anyone find a solution to this problem?
  I was thinking:
  Creating virtual records in a special isUnique validation rule and
  not only checking on isUnique in the DB but also comparing the value
  to all the previously checked ones.

  If you don't do it this way, some of your records will just be omitted
  because the validation fails for them, although saveAll() with
  validate=first returned true in the first place...

 Yes, beforeSave() wouldn't help because it's called for each individual 
 record.

 How about something like this in AppModel?

 function saveAll($data = null, $options = array())
 {
         if (isset($options)  is_array($options) 
 isset($options['validate'])  $options['validate'] !== false)
         {
                 foreach($this-validate as $key = $rule_set)
                 {
                         if (isset($rule_set['rule'])  'isUnique' == 
 $rule_set['rule'])
                         {
                                 $records = Set::extract(
                                         $this-alias.'/'.$key,
                                         $data
                                 );

                                 if (sizeof($records)  array_unique($records))
                                 {
                                         $this-validationErrors[$key] = 
 'non-unique values';
                                 }
                         }
                 }

                 if (sizeof($this-validationErrors))
                 {
                         return false;
                 }
         }
         return parent::saveAll($data, $options);

 }

 Completely untested. And I'm sure it could use some tightening up.

-- 
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: validate unique on batch imports

2011-03-26 Thread cricket
On Sat, Mar 26, 2011 at 9:00 PM, euromark dereurom...@googlemail.com wrote:
 just wrote something myself - although its not tested yet, either:

        /**
         * @param array $data
         * @param array $options
         * - scope (array of other fields as scope - isUnique dependent on
 other fields of the table)
         * - batch (defaults to true, remembers previous values in order to
 validate batch imports)
         * example in model: 'rule' = array ('validateUniqueExt',
 array('scope'=array('belongs_to_table_id', 'user_id'))),
         * //TODO: test!!!
         * 2011-03-27 ms
         */
        function validateUniqueExt($data, $options = array()) {
                foreach ($data as $key = $value) {
                        $fieldName = $key;
                        $fieldValue = $value;
                }
                $defaults = array('batch'=true, 'scope'=array());
                $options = array_merge($defaults, $options);

                # for batch
                if ($options['batch'] !== false  
 !empty($this-batchRecords)) {
                        if (array_key_exists($value,    
 $this-batchRecords[$fieldName])) {
                                return $options['scope'] === 
 $this-batchRecords[$fieldName]
 [$value];
                        }
                }

                # continue with validation
                if (!$this-validateUnique($data, $options['scope'])) {
                        return false;
                }

                # for batch
                if ($options['batch'] !== false) {
                        if (!isset($this-batchRecords)) {
                                $this-batchRecords = array();
                        }
                        $this-batchRecords[$fieldName][$value] = $scope;
                }
                return true;
        }

 this way it doesnt matter if its called from saveAll() or multiple
 validates()

I was confused about $this-batchRecords, thinking you'd need to copy
$this-data to $this-batchRecords. But I see that the validation
method takes care of that. Nifty.

But your foreach loop seems a bit awkward.

list($fieldName, $fieldValue) = $data;

-- 
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: validate unique on batch imports

2011-03-26 Thread Ryan Schmidt

On Mar 26, 2011, at 18:40, euromark wrote:

 I encountered this problem several times with some batch imports or
 multiple form boxes saved together.
 
 You have a validation rule isUnique for the title.
 If you validate all your - lets say 15 - records, they are OK, even if
 two of them have the same name.
 Thats because the validation can only compare the 15 records to the
 current db content, not to each other.

If the title is supposed to be unique, put a UNIQUE index on the title column 
in the database. That will prevent duplicates from being inserted. Though it 
won't necessarily help you get a user-friendly error message, if that's what 
you're after.



-- 
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: validate unique on batch imports

2011-03-26 Thread euromark
exactly, ryan
thats too late if you want to validate all of em first before starting
to insert them into the database

@cricket:
yeah, that was a relict from the old method of mine - from back in the
day when i didnt know about list()^^


On 27 Mrz., 03:26, Ryan Schmidt google-2...@ryandesign.com wrote:
 On Mar 26, 2011, at 18:40, euromark wrote:

  I encountered this problem several times with some batch imports or
  multiple form boxes saved together.

  You have a validation rule isUnique for the title.
  If you validate all your - lets say 15 - records, they are OK, even if
  two of them have the same name.
  Thats because the validation can only compare the 15 records to the
  current db content, not to each other.

 If the title is supposed to be unique, put a UNIQUE index on the title column 
 in the database. That will prevent duplicates from being inserted. Though it 
 won't necessarily help you get a user-friendly error message, if that's what 
 you're after.

-- 
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: validate unique on batch imports

2011-03-26 Thread Ryan Schmidt
On Mar 26, 2011, at 21:45, euromark wrote:
 On 27 Mrz., 03:26, Ryan Schmidt wrote:
 If the title is supposed to be unique, put a UNIQUE index on the title 
 column in the database. That will prevent duplicates from being inserted. 
 Though it won't necessarily help you get a user-friendly error message, if 
 that's what you're after.
 
 exactly, ryan
 thats too late if you want to validate all of em first before starting
 to insert them into the database


I wouldn't say it's too late. Assuming you start a transaction before 
inserting anything, and roll back the transaction if any of them fails, your 
batch of inserts is still atomic. If any of them fails, none of them are 
inserted. I just don't know if you can get a meaningful user-friendly error 
message based on a failure to insert. Though you might be able to. I assume the 
database has a specific error code for duplicate key, which you could check for 
and return a nice error message.



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


can't get past beforeFilter()

2011-03-26 Thread cricket
I've written a controller to handle a few XML-RPC requests, as well a
a basic PHP client to test with. The data is being passed to the
server ok but something's keeping the action from running. I've got
log statements in both beforeFilter and the action itself, but the
latter never show up in the log. Can anyone see anything I've missed?

function beforeFilter()
{
parent::beforeFilter();
$this-Auth-allowedActions = array('handle_request');
$this-layout = $this-autoRender = false;
Configure::write('debug', 0);
App::import('Vendor', 'kd_xmlrpc');

$this-log('beforeFilter');
$this-log($GLOBALS['HTTP_RAW_POST_DATA']);
$this-log($this-params);
}

function isAuthorized()
{
return true;
}

/**
 * Handle a request
 *
 * @access  public
 * @param   void
 * @return  void
 */
public function handle_request()
{
$this-log('handle_request');
$data = XMLRPC_parse($GLOBALS['HTTP_RAW_POST_DATA']);
$this-log($data);

$method_name = XMLRPC_getMethodName($data);

if (!method_exists(__CLASS__, $method_name))
{
$this-__error(
ERROR_XMLRPC_METHOD_NOT_FOUND,
The method you requested, ${method_name}, was not 
found.
);
}

$params = XMLRPC_getParams($data);

$this-setAction($method_name, $params);
}


The log gets:

-- snip --
2011-03-26 23:37:05 Error: beforeFilter
2011-03-26 23:37:05 Error: ?xml version=1.0 ?
methodCall
methodNamememberExists/methodName
params
param
value
stringt...@test.com/string
/value
/param
/params
/methodCall

2011-03-26 23:37:05 Error: Array
(
[pass] = Array
(
)

[named] = Array
(
)

[plugin] =
[controller] = member_rpcs
[action] = handle_request
[form] = Array
(
)

[url] = Array
(
[url] = members/rpc
)

)
-- snip --

That's it--nothing from the action itself. I also added, right after
App::import(...)

$this-log(XMLRPC_parse($GLOBALS['HTTP_RAW_POST_DATA']));

... and it looked fine. So there's no trouble with loading the vendor file.

I'm trying to figure out the best way to monitor what's happening
inside the controller. It seems to me that Auth shouldn't be
interfering, but I guess that's a possibility. But I'm not sure how to
check that, either.

This is the library I'm using, if anyone's interested:
http://keithdevens.com/software/xmlrpc

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