Re: How to do this in cakephp

2009-01-08 Thread Webweave

I'm not sure I understand your question, but if you have a field you
want to save a counter in, you can do this in the model using
countCache: http://book.cakephp.org/view/445/cacheQueries

If on the other hand you need to find the count from some set of
values, you can simply use find('count'): 
http://book.cakephp.org/view/73/Retrieving-Your-Data

On Jan 8, 4:46 am, mona poojapinj...@gmail.com wrote:
 I have code of my controller in which i use normal php codes to fetch
 data from a database and update counter how to do this in cakephp

 ?php
 class EntriesController extends AppController
  {
         var $name = 'Entries';
     var $helpers = array('Html','Form','Javascript','Ajax');
     var $components = array('RequestHandler');
         //var $uses=array('Entry','User');
         function index(){

 -please consider it
 -
     $query=mysql_query(select max(counter) from entries);
     $row=mysql_fetch_array($query);
         $co=$row[0];
         $this-set('co',$co);
         $name=$this-Session-read('User');
         $query1=mysql_query(select id from users where username='$name');
     $row1=mysql_fetch_array($query1);
         $user_id=$row1[0];
         $this-set('user_id',$user_id);
 

         $this-Entry-recursive = 1;
         $this-set('entries', $this-Entry-findAll(null, null, array
 ('Section.id' = 'ASC','Submenu.submenu' = 'ASC')));
     }

          function view($id = null){
          if (!$id){
          $this-Session-setFlash('Invalid id for Entry.');
          $this-redirect('/entries/index');
          }
          $this-set('entry', $this-Entry-read(null, $id));
          }

     function add(){
     $this-set('sections', $this-Entry-Section-find('list',array
 ('fields'='Section.section','Section.id')));
         if (empty($this-data)){
         $this-render();
         }
     else{
         $this-data['Entry']['name'] = $this-data['Entry']['File']['name'];
     $this-data['Entry']['type'] = $this-data['Entry']['File']
 ['type'];
     $this-data['Entry']['size'] = $this-data['Entry']['File']
 ['size'];
         if ($this-Entry-save($this-data)){
 -please check it from
 here---
         $id=mysql_insert_id();
         $query=mysql_query(select max(counter) from entries);
     $row=mysql_fetch_array($query);
     $co=$row[0]+1;
     $q=mysql_query(update entries set counter=$co where id=$id);
 --
         $this-Session-setFlash('The Entry has been saved');
         }
     else{
         $this-Session-setFlash('Please correct errors below.');
         $this-redirect('/entries/add');
         }
     if (move_uploaded_file($this-data['Entry']['File']['tmp_name'],
 WWW_ROOT.'/files/' .$this-data['Entry']['File']['name']))
     {
         echo File uploaded successfully;
     }
     else{
     echo There was an error uploading the file, please try again!;
         }
     $this-redirect('/entries/index');
     }
     }

         function edit($id = null){
         $this-set('sections', $this-Entry-Section-find('list',array
 ('fields'='Section.section','Section.id','recursive' = 1,'page' =
 1,)));
         if (empty($this-data)){
         if (!$id){
         $this-Session-setFlash('Invalid id for Entry');
         $this-redirect('/entries/index');
         }
         $this-data = $this-Entry-read(null, $id);
         }
         else{
 ---please
 check--
     $query=mysql_query(select max(counter) from entries);
     $row=mysql_fetch_array($query);
         $co=$row[0]+1;
     $q=mysql_query(update entries set counter=$co where id=$id);
 
         if ($this-Entry-save($this-data)){
         $this-Session-setFlash('The Entry has been saved');
         $this-redirect('/entries/index');
         }
         else{
         $this-Session-setFlash('Please correct errors below.');
         }
         }
         }

     function delete($id = null){
         if (!$id){
         $this-Session-setFlash('Invalid id for Entry');
         $this-redirect('/entries/index');
         }
         if ($this-Entry-del($id)){
         $this-Session-setFlash('Record deleted successfully');
         $this-redirect('/entries/index');
         }
         }

     function update_select(){
     if(!empty($this-data['Entry']['section_id'])){
     $section_id = (int)$this-data['Entry']['section_id'];
     $options = $this-Entry-Submenu-find('list',array('section_id'=
 $section_id,'recursive' = 

whenever i login i reach to the login page instead of redirecting

2009-01-08 Thread aman batra

i m trying to make a taskmanager and whenever i login i reach to the
login page instead of redirecting to task page

here is my user model
?php
class User extends Appmodel {
var $validate = array(
'firstname'= array('rule'= array('minlength',1),
'message'= 'firstname required'),
'username'= array('rule'= array('minlength',1),
'message'= 'username required'),
'password'= array('rule'= array('minlength',5),
'message'= 'password required'),
'repeat_password' = array(
'rule' = array('CheckPasswordMatch'),
'message' = 'Passwords did not match'),
'email'= array('rule'='email',
'message'= 'email required'));
var $name = 'User';

var $hasMany= array(
'Task'= array(
'classname'='Task',
'order'='Task.start date',
'dependent'= 'true'
)
);
 function CheckPasswordMatch($data) {
return $this-data['User']['password'] ==
Security::hash($this-data['User']['repeat_password'],
null, true);
}
}
?

here is my users_controller

?php
class UsersController extends AppController {
 var $helpers = array('html', 'form');
 var $components=array('Auth');

 function beforeFilter() {
$this-Auth-allow('*');
$this-Auth-fields = array(
'username' = 'username',
'password' = 'password'
);
 }


function add() {
 if(!empty($this-data)) {
if($this-User-save($this-data)) {
   $this-Session-setFlash(User Saved!);
   $this-redirect(array('controller'='users',
'action'='login'));
 }
  }
}
function login()
{
if(!empty($this-data)) {
if($this-Auth-login()) {
$this-Session-setFlash(Hello User);
$this-redirect(array('controller'='tasks', 
'action'='add'));
}
else {
$this-Session-setFlash('here');
}
}
}
function call() {
   $this-User-find('all');
}
}
?

and i have tasks_controller and task model and proper views for each..

can u depict the error???

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Configure Values being replaced by 'N;' using Bakery tutorial

2009-01-08 Thread timtrice

I'm copying the following tutorial:

http://bakery.cakephp.org/articles/view/simply-storing-config-values-in-the-db

I noticed my value, which was 'Test', was being put into the DB as
'N;'.  The key remained correct.

I found that on an empty table, writing a key the wrong value would be
inserted into the DB ('MyApp.Test' would be inserted as 'MyApp.N;').
When i would attempt to read the key using the script in the tutorial,
I would return a variable with the value of 's'.

I started putting echo()'s in various parts of the writecfg().  For
some reason, the script would input the correct values into the DB.
Executing the getcfg() or Configure::read() would return the correct
value.  However, when I removed ALL echo()'s from the script, it
resumed to inserting 'N;' (without quotes, with semicolon) into the
DB.  NOTE that all write's were done on an empty table.

It leads me to believe that it's not the tutorial itself, but rather
the Configure class itself that causes this.

I am using Cake 1.2.0.7962 Final.

Is anyone else coming across these errors?  I've tried searching via
Trac and Google but the semicolon is ignored and nothing is returned
on the various search terms I've used related to this issue.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Containable on deep pagination records

2009-01-08 Thread brian

You want a self join. Try something along these lines:

class FriendOfFriend extends AppModel {

public $name = 'FriendOfFriend';

public $belongsTo = array(
'User' = array(
'className' = 'User',
'foreignKey' = 'user_id'
)
);

public $hasMany = array(
'Friend' = array(
'className' = 'Friend',
'foreignKey' = 'friend_id'
)
);
}

public $paginate = array(
'Friend' = array(
'limit' = 10,
'order' = array('Friend.requestTime' = 'ASC'),
'recursive' = 2,
'contain' = array(
'FriendOfFriend' = array(
'User' = array(
'Country'
)
)

)
)
);


On Thu, Jan 8, 2009 at 6:17 PM, Miles J mileswjohn...@gmail.com wrote:

 Anyone have an idea on this?
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Another question on Baking

2009-01-08 Thread timtrice

rhythmicdevil,

Cake will use Names instead of ID's on immediate children of Models
provided that you are using the fieldname 'Name'.  For example, if
you're relating Posts to Users and you have the 'user_id' field in
your Posts table and you also have the 'name' field in your Users
table, CakePHP will populate the values of the 'Users.Name' in your
Posts view.  Make sense?

If you're child Model is actually a sub-child.  For example, in
the small CMS I am writing, I have the following relationship:

Posts
 - hasMany Meta (Meta table consists of id, meta_tags, and
value).
  -hasOne MetaValue

So my Posts are setup to recognize many Meta values...with each value
(title value, description value, author value, etc.) with each key
having a unique key (title, description, author).  I wanted the
ability to add, on the fly, additional keys (pageviews, for example).
So, my Metas table has a field of 'meta_value_id' which relates to the
'meta_values' table.  Make sense?

Posts won't display via the Bake method the values of the keys stored
in Meta...so I had to add a simple query in the 'view' of my
Controller:

$this-set( 'meta_tags' , $this-Content-Meta-read( null ,
$id ) );

This gives me the correspondeing information from my secondary table
(related).  A little PHP and I can have my Posts index view display
the following (example):

TitleMeta
Tag  Value
My first post!
description   My very first post!

If I don't add the little PHP you see above, you get the 'id' field:

TitleMeta
Tag  Value
My first post!
1 My very first post!

See the difference?

I've thought that the finderQuery or counterQuery in the Posts model
could make this easier.  Perhaps it does.  But I've yet to find good
information to suggest so and when I've played with it I've gotten
nothign but erros using the Christmas release.

I hope I haven't confused you too much!


On Jan 8, 4:59 pm, rhythmicde...@gmail.com rhythmicde...@gmail.com
wrote:
 So first, this Bake is pretty impressive in all that it auto builds. I
 must say the team did a ton of work to make this happen.

 Ok so I just did my first run and I have a bunch of views, models and
 controllers. They all seem to work. The question I have is this:

 I have several inter-related models where one supplies a list for a
 select list in another. For instance:

 IngredientType should supply a list of ingredient_types to Ingredient
 so that in the view you would get a select list of those ingredient
 types.

 What I am getting is the IDs and not the name fields.

 Is this correct or did I make a mistake in a definition somewhere.

 I guess my question is. should I expect those fields to have names?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling methods that are within HABTM Join Models

2009-01-08 Thread mark_story

need to define a with key and include the name of the Join model.  It
was a bug that auto loaded the model in the past for you.

-Mark

On Jan 8, 6:17 pm, bunwich bunw...@gmail.com wrote:
 Hi,
 I've been playing with 1.2 final and was having problems calling -find
 ('all') on a HABTM join table. By convention you don't create a
 AppModel .php file for a Join table in a HABTM relationship, but since
 i had specific queries i needed to make, the file was created.

 In simple terms A and C have a HABTM relationship and they both use B
 as the join table.

 I then have a method within B that is called like this:
 $this-A-B-foo());

 This worked in one of the RC's, but doesn't any more in the final. I
 have an inkling why it should or shouldn't, but maybe someone can shed
 some light on this:

 ** Example *
 // has fields (id, name)
 class User extends AppModel {
     var $hasAndBelongsToMany = array('Car');

 }

 // has fields (id, name)
 class Car extends AppModel {
     var $hasAndBelongsToMany = array('User');

 }

 // has fields (user_id, car_id, role_id)
 class UsersCar extends AppModel {
     var $belongsTo = array('User', 'Car');

     function getAllOwners()
         return $this-find('all', array('conditions' = array
 ('UserCar.role_id' = 3));
     }

 }

 *** Error ***
 In previous RC's I was able to call sub methods
 pr($this-User-UsersCar-getAllOwners());

 In 1.2 Final I get this error.

 Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
 check the manual that corresponds to your MySQL server version for the
 right syntax to use near 'fuck' at line 1 [CORE\cake\libs\model
 \datasources\dbo_source.php, line 514]

 Query: getAllOwner

 *** Problem ***
 What appears to be happening is that UsersCar doesn't get
 automatically instantiated when the HABTM relationship is
 created...maybe :)

 *** The workaround ***
 in
 class User extends AppModel {
     var $hasAndBelongsToMany = array('Car');
     var $hasMany = array('UsersCar');      // this is now required in
 1.2 Final

 }

 So I can see why this is necessary, as it was assumed the Join Table
 was instantiated when the HABTM was declared. In previous RC's it was
 assumed that UsersCar was instantiated if User had a HABTM to Car.

 One other note from the other postings that I've been reading, do I
 need to know add a primary key to the Join Table UsersCar? (ie a new
 field called 'id')

 Any comments would be appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: File component?

2009-01-08 Thread Brenda

Thanks, I got that to work by doing the App:import and then creating
instances of the file object for each file I needed to delete.

I wonder why file isn't included in the cookbook?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



belongsTo not working on a HABTM

2009-01-08 Thread Miles J

My tables: entries, topics, entries_topics

Now all works fine when grabbing data from Entry or Topic. But when I
try to grab data from EntriesTopic, my belongs to are not even
working. Ive tried so many variations and nothing is working.

?php
// entries_topic.php
class EntriesTopic extends AppModel {
var $belongsTo = array('Topic', 'Entry');
}
?

And my find query:

debug($this-EntriesTopic-find('all', array('conditions' = array
('EntriesTopic.topic_id' = 2), 'recursive' = 2)));

And this is the output. No matter what I change in recursive or
associations, I cant get any extra data.

Array
(
[0] = Array
(
[EntriesTopic] = Array
(
[id] = 6
[entry_id] = 4
[topic_id] = 2
)

)

[1] = Array
(
[EntriesTopic] = Array
(
[id] = 13
[entry_id] = 8
[topic_id] = 2
)

)

)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Calling methods that are within HABTM Join Models

2009-01-08 Thread brian

On Thu, Jan 8, 2009 at 6:17 PM, bunwich bunw...@gmail.com wrote:

 Hi,
 I've been playing with 1.2 final and was having problems calling -find
 ('all') on a HABTM join table. By convention you don't create a
 AppModel .php file for a Join table in a HABTM relationship, but since
 i had specific queries i needed to make, the file was created.

 In simple terms A and C have a HABTM relationship and they both use B
 as the join table.

 I then have a method within B that is called like this:
 $this-A-B-foo());

 This worked in one of the RC's, but doesn't any more in the final. I
 have an inkling why it should or shouldn't, but maybe someone can shed
 some light on this:

 ** Example *
 // has fields (id, name)
 class User extends AppModel {
var $hasAndBelongsToMany = array('Car');
 }

 // has fields (id, name)
 class Car extends AppModel {
var $hasAndBelongsToMany = array('User');
 }

 // has fields (user_id, car_id, role_id)
 class UsersCar extends AppModel {
var $belongsTo = array('User', 'Car');

function getAllOwners()
return $this-find('all', array('conditions' = array
 ('UserCar.role_id' = 3));
}
 }


It's probably only a typo but it's worth pointing out that you have
both UsersCar and UserCar there. You should name the join model
UsersCar.


class UsersCar extends AppModel
{
public $name = 'UsersCar';
public $useTable = 'cars_users';// proper name order for the table
public $belongsTo = array('Car', 'User');

(or, actually, CarsUser--I'm not sure that the alphabetical order is
important with this type of model)

 Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
 check the manual that corresponds to your MySQL server version for the
 right syntax to use near 'fuck' at line 1 [CORE\cake\libs\model
 \datasources\dbo_source.php, line 514]

That must be some table schema! What are those users doing in each others' cars?

 Query: getAllOwner

 *** Problem ***
 What appears to be happening is that UsersCar doesn't get
 automatically instantiated when the HABTM relationship is
 created...maybe :)

 *** The workaround ***
 in
 class User extends AppModel {
var $hasAndBelongsToMany = array('Car');
var $hasMany = array('UsersCar');  // this is now required in
 1.2 Final
 }

 So I can see why this is necessary, as it was assumed the Join Table
 was instantiated when the HABTM was declared. In previous RC's it was
 assumed that UsersCar was instantiated if User had a HABTM to Car.

 One other note from the other postings that I've been reading, do I
 need to know add a primary key to the Join Table UsersCar? (ie a new
 field called 'id')


From what I understand, Cake does create the join model on the fly
(and, perhaps it's your naming convention which is the sticking point)
but creating a class for the model is useful for the sort of thing
you're trying to accomplish. As for the id primary key, I believe it's
not strictly necessary, though it will cut down on the number of
queries necessary to dig down to the desired set.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: really simple authentication

2009-01-08 Thread brian

You might as well leave the hashed password in bootstrap.php then, and
have your controller check against that.

Either that, or use ht[digest|passwd] (though you'd be stuck with the
browser's ugly login box).

On Thu, Jan 8, 2009 at 4:19 PM, fain182 fain...@gmail.com wrote:

 hello,
 I need to protect a whole cakephp site under one password, i don't
 need user, groups, registration etc.. so i don't want use ACL for a
 simple thing like this.. how can I do? there is a simpler
 authentucation component? other ways?

 thank you,
 pietro

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to distinguish param and action in cakephp's URL

2009-01-08 Thread Luenyar

If you wanted to do this, you would have to setup a route for '/*' and
point it to whichever controller/action is going to accept your
param.  So:

Router::connect('/*', array('controller' = 'users', 'action' =
'view'));

would allow you to get the address 'www.mysite.com/users/view/joe' by
entering/linking to 'www.mysite.com/joe'.

BUTthen you lose the ability to use, for example, 'www.mysite.com/
posts/' to get to 'www.mysite.com/posts/index' unless you set up a
specific route for it BEFORE your  '/*' route. So you would need:

Router::connect('/posts', array('posts','index'));
Router::connect('/announcements', array('announcements','index'));
/*etc for every controller you want to access in this way*/
Router::connect('/*', array('controller' = 'users', 'action' =
'view'));

Plus, maybe there are other consequences that you might find when
testing it if you don't specify enough routes.  See if that is what
you are looking for.

HTH,
Milton


On Jan 7, 10:02 pm, Rimoe meiyo...@gmail.com wrote:
 Yes, I can do these.but use the linkhttp://www.mysite.com/param1
 I get a error that have no the controller of  param1controller.php
 so, I think where should I need to set it,
 let the cakephp think the param1 is a param.

 Thanks.

 2009/1/7 gearvOsh mileswjohn...@gmail.com



  I dont think there is a cake setting, just do this during signup.

  $restricted = array('users','pages','controllername');

  if (in_array($usernameVar, $restricted)) {
  // do not allow registration
  }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Data validation doesn't work

2009-01-08 Thread josnidhin

I tried this still not working..If I use scaffolding to test
everything works fine validation errors shows up.
When I use my view then the problem arises.

On Jan 8, 2:29 pm, Nature Lover nature_lover1...@yahoo.co.in wrote:
 Hi!

 try by mentioning also the model name while outputting errors, so the
 view code will become:

 ?echo $form-create('user', array('action' = 'signup'));?
 fieldset
          legendSignup/legend
      ?php
                  echo $form-input('User.users_name',array
 (label=Name:));
                  echo $form-error('User.users_name');

                  echo $form-input('User.users_email',array
 (label=Email:));
                 echo $form-error('User.users_email');

                  echo $form-input('User.users_password',array
  (label=Password:,type=password));
                  echo $form-input('User.password_confirm',array
 ('label'='Password
  Confirm:','type'='password'));
                  echo $form-error('User.users_password');
                  echo $form-error('User.password_confirm');
          ?
 /fieldset
 ?echo $form-end(Sign Up);?

 Thanks!

 On Jan 8, 10:34 am,josnidhinjosnid...@gmail.com wrote:

  ?echo $form-create('user', array('action' = 'signup'));?
  fieldset
          legendSignup/legend
      ?php
                  echo $form-input('users_name',array(label=Name:));
                  echo $form-error('users_name');

                  echo $form-input('users_email',array(label=Email:));
                  echo $form-error('users_email');

                  echo $form-input('users_password',array
  (label=Password:,type=password));
                  echo 
  $form-input('password_confirm',array('label'='Password
  Confirm:','type'='password'));
                  echo $form-error('users_password');
                  echo $form-error('password_confirm');
          ?
  /fieldset
  ?echo $form-end(Sign Up);?

  This is how my view looks like. I am still not getting the errors. But
  my validation is working as it only inserts into the database when the
  data is correct.

  var $validate = array(
          users_name = array(rule = alphaNumeric,required =
  true,allowEmpty=false,message = Alphabets and numbers only),
          users_email = array(
                  email=array(rule=email,message=Invalid email
  address,required = true,allowEmpty=false),
                  unique=array(rule=array
  (validateUniqueEmail),message=This Email is already in
  use,required = true,allowEmpty=false)),
          users_password = array(rule = array
  (confirmPassword,password),required=true,allowEmpty=false,message
  = Password do not match),
                  password_confirm = array(rule = 
  alphaNumeric,required =
  true)
  );

  This is how my validate array in model looks like confirmPassword and
  validateUniqueEmail are function that I wrote. I am not able to figure
  out why this is happening.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to distinguish param and action in cakephp's URL

2009-01-08 Thread Rimoe
Thank You for your answer.I think this is what I want to get.

but I have too many controllers,
this is a big task to add so many routers,
and I will add more many controllers.
so,   is the routes.php support the Regular expression?
because all of my controllers are end by 's'.
for example ,
can I write it like this?
[
Router::connect('/*s/*');
Router::connect('/*', array('controller' = 'users', 'action' = 'views',
'view'));
]

Rimoe


2009/1/8 Luenyar luen...@gmail.com


 If you wanted to do this, you would have to setup a route for '/*' and
 point it to whichever controller/action is going to accept your
 param.  So:

 Router::connect('/*', array('controller' = 'users', 'action' =
 'view'));

 would allow you to get the address 'www.mysite.com/users/view/joe' by
 entering/linking to 'www.mysite.com/joe'.

 BUTthen you lose the ability to use, for example, 'www.mysite.com/
 posts/ http://www.mysite.com/posts/' to get to '
 www.mysite.com/posts/index' unless you set up a
 specific route for it BEFORE your  '/*' route. So you would need:

 Router::connect('/posts', array('posts','index'));
 Router::connect('/announcements', array('announcements','index'));
 /*etc for every controller you want to access in this way*/
 Router::connect('/*', array('controller' = 'users', 'action' =
 'view'));

 Plus, maybe there are other consequences that you might find when
 testing it if you don't specify enough routes.  See if that is what
 you are looking for.

 HTH,
 Milton


 On Jan 7, 10:02 pm, Rimoe meiyo...@gmail.com wrote:
  Yes, I can do these.but use the linkhttp://www.mysite.com/param1
  I get a error that have no the controller of  param1controller.php
  so, I think where should I need to set it,
  let the cakephp think the param1 is a param.
 
  Thanks.
 
  2009/1/7 gearvOsh mileswjohn...@gmail.com
 
 
 
   I dont think there is a cake setting, just do this during signup.
 
   $restricted = array('users','pages','controllername');
 
   if (in_array($usernameVar, $restricted)) {
   // do not allow registration
   }
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



view cacheing with url variables?

2009-01-08 Thread DRE
if I have this :
Router::connect(
'/search/:crit',
array('controller' = 'search', 'action' = 'index'),
array('crit'='(.+)')
);

How do I view cache the output?
Along with var $helpers = array( 'Cache');
I've tried
var $cacheAction = array('index/*' = 3400);
var $cacheAction = array('index/:crit' = 3400);
var $cacheAction = array('index/(.+)' = 3400);

There must be some way to do this.

Thanks!
Andre

-- 
DRE
http://www.increasetheknowledge.com
http://www.theanticool.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: view cacheing with url variables?

2009-01-08 Thread DRE
Criminy, it just started to work with var $cacheAction = array('index' =
3400);  I kind of want to say duh but its not totally obvious that it should
have. Or maybe it is. Anyway! On to the next problem.

Andre


On Thu, Jan 8, 2009 at 9:45 PM, DRE mountaing...@gmail.com wrote:

 if I have this :
 Router::connect(
 '/search/:crit',
 array('controller' = 'search', 'action' = 'index'),
 array('crit'='(.+)')
 );

 How do I view cache the output?
 Along with var $helpers = array( 'Cache');
 I've tried
 var $cacheAction = array('index/*' = 3400);
 var $cacheAction = array('index/:crit' = 3400);
 var $cacheAction = array('index/(.+)' = 3400);

 There must be some way to do this.

 Thanks!
 Andre

 --
 DRE
 http://www.increasetheknowledge.com
 http://www.theanticool.com




-- 
DRE
http://www.increasetheknowledge.com
http://www.theanticool.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Possible Bug With HABTM Relationships ?

2009-01-08 Thread Kyle Decot

I have a Blog Model  I have a Tag Model. The Tag model is a HABTM
relationship to the Blog model. If I add some tags to a particular
blog post and save it using saveAll and then I go back and then try to
remove all the tags, cakePHP will not remove them all. However if I
only attempt to remove a portion of the tags, then cake will remove
the tags I have selected.

Has anyone else experienced this or am I doing something wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: really simple authentication

2009-01-08 Thread park

The simplest method would be .htaccess password.

On Jan 9, 5:19 am, fain182 fain...@gmail.com wrote:
 hello,
 I need to protect a whole cakephp site under one password, i don't
 need user, groups, registration etc.. so i don't want use ACL for a
 simple thing like this.. how can I do? there is a simpler
 authentucation component? other ways?

 thank you,
 pietro
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to distinguish param and action in cakephp's URL

2009-01-08 Thread Luenyar

I think you can use regex in routes, so probably you could do this.
But then I think you would have to restrict user names to not have 's'
as a last character.  So it might be better for users if you copy/
paste/modify a bunch of routes so they don't gripe when they can't get
an 's' on their user name?

In my opinion I think you are trying to design an inflexible system,
but ultimately it is your design choice.  Good luck =)

On Jan 8, 11:30 pm, Rimoe meiyo...@gmail.com wrote:
 Thank You for your answer.I think this is what I want to get.

 but I have too many controllers,
 this is a big task to add so many routers,
 and I will add more many controllers.
 so,   is the routes.php support the Regular expression?
 because all of my controllers are end by 's'.
 for example ,
 can I write it like this?
 [
 Router::connect('/*s/*');
 Router::connect('/*', array('controller' = 'users', 'action' = 'views',
 'view'));
 ]

 Rimoe

 2009/1/8 Luenyar luen...@gmail.com



  If you wanted to do this, you would have to setup a route for '/*' and
  point it to whichever controller/action is going to accept your
  param.  So:

  Router::connect('/*', array('controller' = 'users', 'action' =
  'view'));

  would allow you to get the address 'www.mysite.com/users/view/joe'by
  entering/linking to 'www.mysite.com/joe'.

  BUTthen you lose the ability to use, for example, 'www.mysite.com/
  posts/ http://www.mysite.com/posts/' to get to '
 www.mysite.com/posts/index'unless you set up a
  specific route for it BEFORE your  '/*' route. So you would need:

  Router::connect('/posts', array('posts','index'));
  Router::connect('/announcements', array('announcements','index'));
  /*etc for every controller you want to access in this way*/
  Router::connect('/*', array('controller' = 'users', 'action' =
  'view'));

  Plus, maybe there are other consequences that you might find when
  testing it if you don't specify enough routes.  See if that is what
  you are looking for.

  HTH,
  Milton

  On Jan 7, 10:02 pm, Rimoe meiyo...@gmail.com wrote:
   Yes, I can do these.but use the linkhttp://www.mysite.com/param1
   I get a error that have no the controller of  param1controller.php
   so, I think where should I need to set it,
   let the cakephp think the param1 is a param.

   Thanks.

   2009/1/7 gearvOsh mileswjohn...@gmail.com

I dont think there is a cake setting, just do this during signup.

$restricted = array('users','pages','controllername');

if (in_array($usernameVar, $restricted)) {
// do not allow registration
}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Sanitization

2009-01-08 Thread Steven Wright

Thanks I will try that.
 

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Penfold
Sent: Thursday, January 08, 2009 7:27 PM
To: CakePHP
Subject: Re: Sanitization


Try

$this-data = Sanitize::escape($this-data);

On 8 Jan, 23:23, rhythmicde...@gmail.com rhythmicde...@gmail.com
wrote:
 Question about Sanitization. Am I right in thinking that I need to 
 process each field in my submitted data and then rebuild the array to 
 send to my model for saving? That doesnt seem right to me from the 
 point of view of the framework. I would have thought that I could 
 simply pass it my data array or a string and it would return the 
 correct structure sanitized.

 Unless I am completely doing it wrong of course.

                         $san = new Sanitize();

                         $this-data = $san-escape($this-data);

 That cause all sorts of pretty errors because I am assuming escape 
 expects a single string.

 In this case I will have to write a function that accepts and then 
 returns my data array. No big deal, just as I said I am surprised that 
 CakePHP does not do this.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Sanitization

2009-01-08 Thread Steven Wright

Rock! Thanks for the help.
 

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Dardo Sordi Bogado
Sent: Thursday, January 08, 2009 9:17 PM
To: cake-php@googlegroups.com
Subject: Re: Sanitization


 Question about Sanitization. Am I right in thinking that I need to 
 process each field in my submitted data and then rebuild the array to 
 send to my model for saving? That doesnt seem right to me from the 
 point of view of the framework. I would have thought that I could 
 simply pass it my data array or a string and it would return the 
 correct structure sanitized.

No, cake will (SQL)escape your data before saving to database and
(HTML)escape when output through cake helpers, but cake will not strip
(automatically) dangerous data (like script tags) from user input, you need
to sanitize/escape that one when you output directly in views (without using
cake helpers), luckily cake provides the h() and
Sanitize::stripWhat() methods.

 Unless I am completely doing it wrong of course.

$san = new Sanitize();

$this-data = $san-escape($this-data);

 That cause all sorts of pretty errors because I am assuming escape 
 expects a single string.

 In this case I will have to write a function that accepts and then 
 returns my data array. No big deal, just as I said I am surprised that 
 CakePHP does not do this.
 




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: hasMany + belongsTo relationship problem

2009-01-08 Thread Ernesto

Hello and thx for the fast response.

i forgot to paste the var $primaryKey in my model's code. sorry.

everything is working fine in my app. i just can't fetch Location
Types starting from persons. i'll take a look @ containable behaviour.

thx again

On 8 Gen, 21:43, Webweave webwe...@gmail.com wrote:
 Since you are using non-standard names for your ID columns, you need
 to specify $primaryKey in your models, so your Person model, you would
 need:

 $primaryKey = 'location_id';

 If you set debug to 2 or 3, you'll see the queries being executed. You
 may need to set recursive to get the non-related data too, see:

 On Jan 8, 8:09 am, Ernesto e.fanz...@gmail.com wrote:



  Hello.

  i have 3 models
  - Person
  - Location
  - Location_Type

  pointing respectively @ 3 tables:

  Persons:
  person_id
  name
  surname

  Locations:
  location_id
  person_id
  location_type_id
  address
  country

  Location_Types:
  location_type_id
  description

  the 3 models are linked as follow:
  Person hasMany Location
  Location belongsTo Location_Type

  here's the models' code

  class person extends AppModel {
          var $hasMany = array(
                  Locations = array(
                          className = Location,
                          foreignKey = location_id,
                          dependent = true
                  )
          );

  }

  class location extends AppModel {
          var $belongsTo = array(
                  Location_Type = array(
                          className = LocationType,
                          foreignKey = location_type_id,
                          dependent = true
                  )
          );

  }

  I can't find out why the Location_Type's data is not showing when i
  load data from the Person model
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problems with using set()

2009-01-08 Thread volka

Great! Thanks a lot!

On 9 Jan., 03:18, brian bally.z...@gmail.com wrote:
 The paginate method calls find() internally. So, what you've done here
 is run the find() yourself, altered the data, then set the data to the
 results of another (paginated) result. It's, more or less, as if you
 called find() again.

 What you should do is create an afterFind() method in the *model*
 which adds the new field. Have a look at the CookBook or the API.
 Better yet, go through the source of a few behaviors (the ones which
 utilise afterFind() at any rate) to get an idea how it works. The
 AutoFieldBehavior comes to mind.

 The important thing to remember is that you must return the results
 from the method.

 On Thu, Jan 8, 2009 at 4:05 PM, volka volker.b...@googlemail.com wrote:

  Hi there,

  I have the following index() method in my controller:

  function index() {
                 $travelogues = $this-Travelogue-find('all');
                 $i = 0;
                 foreach (  $travelogues as $travelogue):
                         if (!empty($travelogue['Travelogue']['gallery'])){
                                 $travelogues[$i]['Images'] = abcdef;
                                 debug($travelogues);
                         }
                         $i++;
                 endforeach;
                 $this-set('travelogues', $this-paginate());
         }

  The purpose is to append a key called 'Images' to $travelogues.
  The debug($travelogues) shows that it worked.

  But debugging $travelogues in my view index.ctp shows no 'Image'.
  What did I do wrong here?

  Thanks for any help.

  Kind regards!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---