Re: Validation + Mongo Datasource

2011-12-28 Thread RhythmicDevil
bump x 1

On Dec 27, 9:59 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi all,
 I am trying to get validation working for my application but I am
 getting some weirdness. I have setup a custom RBAC implementation
 using MongoDB and Ichikaway's datasource.

 https://github.com/ichikaway/mongoDB-Datasource

 I am working on validating in the Groups Model. This is my validate
 property:

     public $validate = array(
         'group' = array(
             'isUnique' = array(
                 'rule' = 'isUnique',
                 'required' = true,
                 'message' = 'Duplicate Group',
             ),
             'notEmpty' = array(
                 'rule' = 'notEmpty',
                 'required' = true,
                 'message' = 'Group name is required',
             )
         )
     );

 And I also have a validates() method

     public function validates()
     {
         parent::validates();

         var_dump($this);
     }

 So a couple of different scenarios give different results but not the
 one I need.

 1. If I wrap the Group-save() call in the controller like this:

            if ($this-Group-validates())
             {
                 if ($this-Group-save($this-data))
                 {
                     $this-flash(__('Group Created.', true),
 array('action' = 'index'));
                 }
             }

 I always get a validation error when I edit saying that the group name
 must be unique.

 2. If I dont wrap the save method in the controller and only supply
 the Model::validate property and the Model::validates() method then
 the validation works but there is no notification. I have dumped out
 the contents of the Model but I cant see anything that I can use to
 determine what validation failed.

 3. If I remove the Model::validates() method the Model acts like the
 record saves but does not actually update the record. In other words
 the record does not change unless the new data does not violate any of
 the validation rules.

 Ok so I am out in the weeds. I realize I have to do some coding to
 make this work, but I am not sure where that code should go. Does the
 Datasource have something to do with filling the validation errors
 array?

 What I really want it to make sure that the validation errors array
 gets something so I can determine what happened and inform the user.

 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


Validation + Mongo Datasource

2011-12-27 Thread RhythmicDevil
Hi all,
I am trying to get validation working for my application but I am
getting some weirdness. I have setup a custom RBAC implementation
using MongoDB and Ichikaway's datasource.

https://github.com/ichikaway/mongoDB-Datasource

I am working on validating in the Groups Model. This is my validate
property:

public $validate = array(
'group' = array(
'isUnique' = array(
'rule' = 'isUnique',
'required' = true,
'message' = 'Duplicate Group',
),
'notEmpty' = array(
'rule' = 'notEmpty',
'required' = true,
'message' = 'Group name is required',
)
)
);

And I also have a validates() method

public function validates()
{
parent::validates();

var_dump($this);
}


So a couple of different scenarios give different results but not the
one I need.

1. If I wrap the Group-save() call in the controller like this:

   if ($this-Group-validates())
{
if ($this-Group-save($this-data))
{
$this-flash(__('Group Created.', true),
array('action' = 'index'));
}
}

I always get a validation error when I edit saying that the group name
must be unique.

2. If I dont wrap the save method in the controller and only supply
the Model::validate property and the Model::validates() method then
the validation works but there is no notification. I have dumped out
the contents of the Model but I cant see anything that I can use to
determine what validation failed.

3. If I remove the Model::validates() method the Model acts like the
record saves but does not actually update the record. In other words
the record does not change unless the new data does not violate any of
the validation rules.


Ok so I am out in the weeds. I realize I have to do some coding to
make this work, but I am not sure where that code should go. Does the
Datasource have something to do with filling the validation errors
array?

What I really want it to make sure that the validation errors array
gets something so I can determine what happened and inform the user.


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: MongoDB $or + $regex

2011-12-12 Thread RhythmicDevil
Bump!

On Dec 10, 1:54 pm, RhythmicDevil rhythmicde...@gmail.com wrote:
 I have been going around and around with this this morning trying to
 sort out the correct syntax for an $or containing multiple $regex

 So in RockMongo I use this:

 {
 $or : [
         {ingredient : {$regex : /^aru/i}},
         {ingredient : {$regex : /^bro/i}},
         ]

 }

 It returns two items from my DB

 However I cannot figure out the correct syntax to use to accomplish
 the same thing using Cake's MongoDB datasource. The method below only
 returns an item that matches on the last item in the $conditions
 array.

     public function test()
     {

          //'Ingredient.ingredient'
         $conditions = array();
         $conditions[] = array('Ingredient.ingredient' =
 array('$regex' = new MongoRegex('/^arug/i')));
         $conditions[] = array('Ingredient.ingredient' =
 array('$regex' = new MongoRegex('/^bro/i')));

         $query = array(
             'limit' = 15,
             'order' = array(
                 'Ingredient.ingredient' = 'asc',
                 'Ingredient.type' = 'asc'),
             'conditions' = array('$or' = $conditions)
         );

         var_dump($query);

         $ingredients = $this-Ingredient-find('all', $query);
         var_dump($ingredients);
         exit();
     }

 Any help would be appreciated.

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

2011-12-12 Thread RhythmicDevil
Hi Geoff, thanks for the reply. Was trying to deny access to a
particular user/group to a controller. I had originally setup my
AppController::beforeFilter like you have shown. But when a user/group
tried to access a controller they did not have permission for they
were allowed access. If I run the Acl-check() method I can see that
the user is denied access. The reason I added all the stuff to my
beforeFilter() was because it seemed to be the only way to prevent
access to the controller.


On Dec 9, 5:26 pm, Geoff Douglas drdouglas...@gmail.com wrote:
 Are you trying to set up your application for the first time? Or are you
 trying to create some other functionality.
 If it's the first setup, it looks like you are over thinking this a bit.

 $this-Auth-actionPath = 'controllers/';
 $this-Auth-authorize = 'actions';
 $this-Auth-loginAction = array('controller' = 'users', 'action' =
 'login','plugin'='');
 $this-Auth-logoutRedirect = array('controller' = 'users', 'action' =
 'login','plugin'='');
 $this-Auth-loginRedirect = array('controller' =
 'pages','action'='home','plugin'='');

 These are the lines I have in my App Controller beforeFilter(). The Auth
 component does all the checking for you. Once the Session is
 Authenticated you don't have to worry about it.
 I only use the Auth-check method, if I am doing something else as part of
 another process... which is not very often.

 Let me know.

-- 
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: MongoDB $or + $regex

2011-12-12 Thread RhythmicDevil
One more time?

On Dec 12, 8:07 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Bump!

 On Dec 10, 1:54 pm, RhythmicDevil rhythmicde...@gmail.com wrote:







  I have been going around and around with this this morning trying to
  sort out the correct syntax for an $or containing multiple $regex

  So in RockMongo I use this:

  {
  $or : [
          {ingredient : {$regex : /^aru/i}},
          {ingredient : {$regex : /^bro/i}},
          ]

  }

  It returns two items from my DB

  However I cannot figure out the correct syntax to use to accomplish
  the same thing using Cake's MongoDB datasource. The method below only
  returns an item that matches on the last item in the $conditions
  array.

      public function test()
      {

           //'Ingredient.ingredient'
          $conditions = array();
          $conditions[] = array('Ingredient.ingredient' =
  array('$regex' = new MongoRegex('/^arug/i')));
          $conditions[] = array('Ingredient.ingredient' =
  array('$regex' = new MongoRegex('/^bro/i')));

          $query = array(
              'limit' = 15,
              'order' = array(
                  'Ingredient.ingredient' = 'asc',
                  'Ingredient.type' = 'asc'),
              'conditions' = array('$or' = $conditions)
          );

          var_dump($query);

          $ingredients = $this-Ingredient-find('all', $query);
          var_dump($ingredients);
          exit();
      }

  Any help would be appreciated.

  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


MongoDB $or + $regex

2011-12-10 Thread RhythmicDevil
I have been going around and around with this this morning trying to
sort out the correct syntax for an $or containing multiple $regex

So in RockMongo I use this:

{
$or : [
{ingredient : {$regex : /^aru/i}},
{ingredient : {$regex : /^bro/i}},
]
}

It returns two items from my DB

However I cannot figure out the correct syntax to use to accomplish
the same thing using Cake's MongoDB datasource. The method below only
returns an item that matches on the last item in the $conditions
array.

public function test()
{

 //'Ingredient.ingredient'
$conditions = array();
$conditions[] = array('Ingredient.ingredient' =
array('$regex' = new MongoRegex('/^arug/i')));
$conditions[] = array('Ingredient.ingredient' =
array('$regex' = new MongoRegex('/^bro/i')));

$query = array(
'limit' = 15,
'order' = array(
'Ingredient.ingredient' = 'asc',
'Ingredient.type' = 'asc'),
'conditions' = array('$or' = $conditions)
);

var_dump($query);

$ingredients = $this-Ingredient-find('all', $query);
var_dump($ingredients);
exit();
}


Any help would be appreciated.

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


ACL RBAC

2011-12-09 Thread RhythmicDevil
Hi all, I am working on implementing RBAC using ACL. I am really close
but I am getting an error and I am hoping you can shed some light on
it. I have pasted my entire ACO and ARO trees below for reference.

When I run the following using the Cake console it works as expected:

[swright@swright-dev app]$ cake acl check Group.4 controllers/
Solidcores *
Group.4 is allowed.

***

However if I do this in my AppController::beforeFilter():

var_dump('Acl Check Result',
  $this-Acl-check(
  'Group.' . $this-Session-read('Auth.User.group_id'),
  'controllers/' . $this-name,
  *
)
);

***

I get the following output in my browser:

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in
permissions check.  Node references:
Aro: Group.4
Aco: controllers/Solidcores [CORE/cake/libs/controller/components/
acl.php, line 273]

string 'Acl Check Result' (length=16)

boolean false

***

Shouldn't I get the same result?


***
ARO and ACO Tree dumps


[swright@swright-dev app]$ cake acl view aro
Aro tree:
---
  [1] Group.4
[4] User.4
[7] User.7
  [2] Group.5
[5] User.5
  [3] Group.6
[6] User.6
---
[swright@swright-dev app]$ cake acl view aco
Aco tree:
---
  [1] controllers
[2] Pages
  [3] display
  [4] add
  [5] edit
  [6] index
  [7] view
  [8] delete
[9] AnalystUi
  [10] index
  [11] add
  [12] edit
  [13] view
  [14] delete
[15] ThreatCenter
  [16] index
  [17] add
  [18] edit
  [19] view
  [20] delete
[21] GtiData
  [22] index
  [23] add
  [24] edit
  [25] view
  [26] delete
[27] PocDemos
  [28] index
  [29] add
  [30] edit
  [31] view
  [32] delete
[33] Projects
  [34] index
  [35] add
  [36] edit
  [37] view
  [38] delete
[39] Products
  [40] index
  [41] add
  [42] edit
  [43] view
  [44] delete
[45] Users
  [46] login
  [47] logout
  [48] index
  [49] view
  [50] add
  [51] edit
  [52] delete
[53] Wam
  [54] index
  [55] add
  [56] edit
  [57] view
  [58] delete
[59] Solidcores
  [60] index
  [61] processed_count
  [62] performance
  [63] add
  [64] edit
  [65] view
  [66] delete
[67] ThreatVectors
  [68] index
  [69] add
  [70] edit
  [71] view
  [72] delete
[73] Botnets
  [74] index
  [75] add
  [76] edit
  [77] view
  [78] delete
[79] Tests
  [80] index
  [81] add
  [82] edit
  [83] view
  [84] delete
[85] Groups
  [86] index
  [87] view
  [88] add
  [89] edit
  [90] delete
[91] Main
  [92] index
  [93] add
  [94] edit
  [95] view
  [96] delete
[97] GtiApi
  [98] index
  [99] add
  [100] edit
  [101] view
  [102] delete
[103] Resources
  [104] index
  [105] add
  [106] edit
  [107] view
  [108] delete
[109] Environments
  [110] index
  [111] add
  [112] edit
  [113] view
  [114] delete
[115] Operations
  [116] index
  [117] add
  [118] edit
  [119] view
  [120] delete
[121] Reports
  [122] index
  [123] add
  [124] edit
  [125] view
  [126] delete
[127] GtiSdk
  [128] index
  [129] add
  [130] edit
  [131] view
  [132] delete

-- 
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: ACL RBAC

2011-12-09 Thread RhythmicDevil
A coworker just clued me in and this is the final statement in
AppController::beforeFilter()


function beforeFilter()
{
/*
 * check(ARO, ACO, [action])
 *
 */
if ($this-Acl-check(array('model' = 'Group', 'foreign_key'
= $this-Session-read('Auth.User.group_id')), $this-name, '*'))
{
var_dump('Allowed');
}
else
{
var_dump('Not Allowed');
}
}


On Dec 9, 10:11 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi all, I am working on implementing RBAC using ACL. I am really close
 but I am getting an error and I am hoping you can shed some light on
 it. I have pasted my entire ACO and ARO trees below for reference.

 When I run the following using the Cake console it works as expected:

 [swright@swright-dev app]$ cake acl check Group.4 controllers/
 Solidcores *
 Group.4 is allowed.

 *** 
 

 However if I do this in my AppController::beforeFilter():

 var_dump('Acl Check Result',
       $this-Acl-check(
           'Group.' . $this-Session-read('Auth.User.group_id'),
           'controllers/' . $this-name,
           *
         )
 );

 *** 
 

 I get the following output in my browser:

 Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in
 permissions check.  Node references:
 Aro: Group.4
 Aco: controllers/Solidcores [CORE/cake/libs/controller/components/
 acl.php, line 273]

 string 'Acl Check Result' (length=16)

 boolean false

 *** 
 

 Shouldn't I get the same result?

 *** 
 
 ARO and ACO Tree dumps

 [swright@swright-dev app]$ cake acl view aro
 Aro tree:
 ---
   [1] Group.4
     [4] User.4
     [7] User.7
   [2] Group.5
     [5] User.5
   [3] Group.6
     [6] User.6
 ---
 [swright@swright-dev app]$ cake acl view aco
 Aco tree:
 ---
   [1] controllers
     [2] Pages
       [3] display
       [4] add
       [5] edit
       [6] index
       [7] view
       [8] delete
     [9] AnalystUi
       [10] index
       [11] add
       [12] edit
       [13] view
       [14] delete
     [15] ThreatCenter
       [16] index
       [17] add
       [18] edit
       [19] view
       [20] delete
     [21] GtiData
       [22] index
       [23] add
       [24] edit
       [25] view
       [26] delete
     [27] PocDemos
       [28] index
       [29] add
       [30] edit
       [31] view
       [32] delete
     [33] Projects
       [34] index
       [35] add
       [36] edit
       [37] view
       [38] delete
     [39] Products
       [40] index
       [41] add
       [42] edit
       [43] view
       [44] delete
     [45] Users
       [46] login
       [47] logout
       [48] index
       [49] view
       [50] add
       [51] edit
       [52] delete
     [53] Wam
       [54] index
       [55] add
       [56] edit
       [57] view
       [58] delete
     [59] Solidcores
       [60] index
       [61] processed_count
       [62] performance
       [63] add
       [64] edit
       [65] view
       [66] delete
     [67] ThreatVectors
       [68] index
       [69] add
       [70] edit
       [71] view
       [72] delete
     [73] Botnets
       [74] index
       [75] add
       [76] edit
       [77] view
       [78] delete
     [79] Tests
       [80] index
       [81] add
       [82] edit
       [83] view
       [84] delete
     [85] Groups
       [86] index
       [87] view
       [88] add
       [89] edit
       [90] delete
     [91] Main
       [92] index
       [93] add
       [94] edit
       [95] view
       [96] delete
     [97] GtiApi
       [98] index
       [99] add
       [100] edit
       [101] view
       [102] delete
     [103] Resources
       [104] index
       [105] add
       [106] edit
       [107] view
       [108] delete
     [109] Environments
       [110] index
       [111] add
       [112] edit
       [113] view
       [114] delete
     [115] Operations
       [116] index
       [117] add
       [118] edit
       [119] view
       [120] delete
     [121] Reports
       [122] index
       [123] add
       [124] edit
       [125] view
       [126] delete
     [127] GtiSdk
       [128] index
       [129] add
       [130] edit
       [131] view
       [132] delete

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

Adding a field to the User in Session

2011-12-09 Thread RhythmicDevil
Hi,
I have Users and Groups. When a user logs in I want the group name to
be part of the record that is stored in Session. Currently I get this:

array (
'id' = '4',
'username' = 'swright',
'group_id' = '4',
'created' = '2011-12-05 11:36:30',
'modified' = '2011-12-05 11:36:30',
)

What I want is this:

array (
'id' = '4',
'username' = 'swright',
'group_id' = '4',
'group' = 'administrators',
'created' = '2011-12-05 11:36:30',
'modified' = '2011-12-05 11:36:30',
)


I figured I could just fetch the group name in the login method after
the user is logged in. However my login method never gets called when
I submit the data. But the user is logged in and redirected to the
appropriate controller/action. The method is called when the login
page is first requested but upon submission of the form it does not
seem to get called again.

So I poked around the Auth component but the login function does not
contain and sort of redirect that I could see. I am using Acl and Auth
so this probably has something to do with it.

Can you explain the execution chain for logging in a user when using
Acl and Auth?

I think there's probably also a way to do it automatically by defining
something in the User model but I am not sure.

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: Adding a field to the User in Session

2011-12-09 Thread RhythmicDevil
Ok thats fair enough. I can do a redirect, get the Group and then
redirect to the final destination. Actually that allows me to also get
a default path per group too.

thanks


On Dec 9, 1:39 pm, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 Look at the autoRedirect property of the Auth component. It allows you to 
 perform logic after login but before redirect - perfect for what you need.

 http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirec...

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote:







  Hi,
  I have Users and Groups. When a user logs in I want the group name to
  be part of the record that is stored in Session. Currently I get this:

  array (
     'id' = '4',
     'username' = 'swright',
     'group_id' = '4',
     'created' = '2011-12-05 11:36:30',
     'modified' = '2011-12-05 11:36:30',
  )

  What I want is this:

  array (
     'id' = '4',
     'username' = 'swright',
     'group_id' = '4',
     'group' = 'administrators',
     'created' = '2011-12-05 11:36:30',
     'modified' = '2011-12-05 11:36:30',
  )

  I figured I could just fetch the group name in the login method after
  the user is logged in. However my login method never gets called when
  I submit the data. But the user is logged in and redirected to the
  appropriate controller/action. The method is called when the login
  page is first requested but upon submission of the form it does not
  seem to get called again.

  So I poked around the Auth component but the login function does not
  contain and sort of redirect that I could see. I am using Acl and Auth
  so this probably has something to do with it.

  Can you explain the execution chain for logging in a user when using
  Acl and Auth?

  I think there's probably also a way to do it automatically by defining
  something in the User model but I am not sure.

  Thanks.

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://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: Adding a field to the User in Session

2011-12-09 Thread RhythmicDevil
Aha, thats much smarter.

While I have your attention, if you dont mind.

What is the proper way to handle when a group is not allowed to access
a particular controller? I have setup my ACL and it appears to be
working properly. But, and I thought this would happen automatically,
how do I stop execution of the requested method and tell the user they
dont have permission? (AppController::beforeFilter() pasted below)

I have a difficult time understanding where Cake's magic stops and
mine is supposed to take over sometimes.

function beforeFilter()
{
/*
 * Dont check ACL if this is the Users controller and the
login in action
 */
if ($this-name != 'Users'  !in_array($this-action,
array('login', 'logout')))
{
/*
 * check(ARO, ACO, [action])
 *
 */
if ($this-Acl-check(array('model' = 'Group',
'foreign_key' = $this-Session-read('Auth.User.group_id')), $this-
name, '*'))
{
var_dump('Allowed');
}
else
{
var_dump('Not Allowed');
return false;
}
}
}




On Dec 9, 1:56 pm, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 Don't do a redirect; place this in your app_controller beforeFilter:

 $this-Auth-autoRedirect = false;

 Then add the code in your users-login method to populate the Auth.User 
 session key and then redirect accordingly.

 Jeremy Burns
 Class Outfit

 http://www.classoutfit.com

 On 9 Dec 2011, at 18:44:50, RhythmicDevil wrote:







  Ok thats fair enough. I can do a redirect, get the Group and then
  redirect to the final destination. Actually that allows me to also get
  a default path per group too.

  thanks

  On Dec 9, 1:39 pm, Jeremy Burns | Class Outfit
  jeremybu...@classoutfit.com wrote:
  Look at the autoRedirect property of the Auth component. It allows you to 
  perform logic after login but before redirect - perfect for what you need.

 http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirec...

  Jeremy Burns
  Class Outfit

 http://www.classoutfit.com

  On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote:

  Hi,
  I have Users and Groups. When a user logs in I want the group name to
  be part of the record that is stored in Session. Currently I get this:

  array (
     'id' = '4',
     'username' = 'swright',
     'group_id' = '4',
     'created' = '2011-12-05 11:36:30',
     'modified' = '2011-12-05 11:36:30',
  )

  What I want is this:

  array (
     'id' = '4',
     'username' = 'swright',
     'group_id' = '4',
     'group' = 'administrators',
     'created' = '2011-12-05 11:36:30',
     'modified' = '2011-12-05 11:36:30',
  )

  I figured I could just fetch the group name in the login method after
  the user is logged in. However my login method never gets called when
  I submit the data. But the user is logged in and redirected to the
  appropriate controller/action. The method is called when the login
  page is first requested but upon submission of the form it does not
  seem to get called again.

  So I poked around the Auth component but the login function does not
  contain and sort of redirect that I could see. I am using Acl and Auth
  so this probably has something to do with it.

  Can you explain the execution chain for logging in a user when using
  Acl and Auth?

  I think there's probably also a way to do it automatically by defining
  something in the User model but I am not sure.

  Thanks.

  --
  Our newest site for the community: CakePHP Video 
  Tutorialshttp://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
  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 
  Tutorialshttp://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


ACL

2011-12-09 Thread RhythmicDevil
What do you do with a user or group that does not have access to a
node? I thought that an ARO would get denied access to an ACO
automatically if the permissions had been set. When my
AppController::beforeFilter() executes I see that the ACL component is
aware that my user is allowed to see the requested resource.

If the ACL component does not automatically prevent returning that
resource and informing the user why then I suppose I am supposed to do
that. Ok thats fine, whats the best approach? My first guess is just
to prevent execution of the requested controller/action.




function beforeFilter()
{
//var_dump($this-Auth-user());
/*
 * Dont check ACL if this is the Users controller and the
login in action
 */
if ($this-name != 'Users'  !in_array($this-action,
array('login', 'logout')))
{
/*
 * check(ARO, ACO, [action])
 *
 */
if ($this-Acl-check(array('model' = 'Group',
'foreign_key' = $this-Session-read('Auth.User.group_id')), $this-
name, '*'))
{
var_dump('Allowed');
}
else
{
var_dump('Not Allowed');
return false;
}
}
}

-- 
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: Shared code for Models but not in AppModel

2011-12-08 Thread RhythmicDevil
Thats great Geoff thank you.

On Dec 7, 5:08 pm, Geoff Douglas drdouglas...@gmail.com wrote:
 I think you have most elements i place... I think the thing that is getting
 confusing is how cake is suppose to load the classes.

 So here's the kicker. Cake only loads models if they are related to
 something that you are using. I will use an example from my world to
 illustrate.

 I have a Prototype Model, that is used in the PrototypesController. This
 model belongs to a Creator (from the users table), and belongs to a
 Designer (also from the users table). I have a User Model, that only
 handles the logic for logging in and out and user Identity stuff. So the
 User model doesn't have any relationship to the Prototype Model.
 I created a Designer Model, that extends the User Model. I can use this
 Designer Model just like the User model, because it inherits all the
 methods, but it can contain it's own relationships to Prototype. It doesn't
 always inherit the properties though, and I will tell you why I like
 that... because you can then do what you want as far as tables go, and
 datasources. So, just because you extend the User model, it doesn't mean
 that you have to use the users table... If how ever you need to get
 properties, you can access them via $this, if they are not static, and
 parent::someProperty if it is static.

 So, as I said in my Prototype Model I have a belongsTo Designer, so I use
 my Designer Model, and NOT the User Model, in that definition. Now in my
 PrototypesController I can access the Design model like any other related
 model using the chain.
 $this-Prototype-Designer-someMethodInEitherDesignerOrUserModel()

 If you are needing to initiate a model on the fly, that's not related, you
 can use ClassRegistry::init('Designer') OR if in a controller I think you
 can use $this-loadModel('Designer') (Which is just a helper to the first
 one) and use it the same way.

 Anyways, hope that helps. Let me know if I can clarify, or didn't explain
 anything clearly.

-- 
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: ACL + Auth = Headache

2011-12-07 Thread RhythmicDevil
Doh! Man I cant believe I missed that. Thank you Geoff. This totally
worked.

public $components = array(
'Acl',
'Session',
'Auth' = array(
'loginRedirect' = array('controller' = 'main', 'action'
= 'index'),
'actionPath' = 'controllers/',
'allow' = array('login')
)
);





On Dec 7, 3:52 am, Geoff Douglas drdouglas...@gmail.com wrote:
 I think what you are missing is an allow for the login method.
 Technically the login method needs to be publicly accessible. So, the
 line you have commented out that says:
 //$this-Auth-allow(array('*'));

 needs to say
 $this-Auth-allow(array('login'));

 This will allow an un-authenticated user to post to that method and
 login.

 Try something like that. Let me know what you see.

 On Dec 6, 8:21 am, RhythmicDevil rhythmicde...@gmail.com wrote:







  I followed the instructions 
  here:http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application
  to learn how to setup ACL and Auth. My two test attempts went smoothly
  and worked as expected. However, now that I am trying it for real its
  failing. I get stuck in this redirect loop and I dont understand why.
  No matter what valid URL I enter, I get a redirect loop.

  This is the beforeFilter in my AppController:

      function beforeFilter()
      {
          parent::beforeFilter();

          //$this-Auth-allow(array('*'));

          //Configure AuthComponent
          $this-Auth-authorize = 'actions';
          /*
           * If the user did not select a controller/action before
  logging in, then
           * this controller/action willbe executed.
           */
          $this-Auth-loginAction = array('controller' = 'users',
  'action' = 'login');
          /*
           * Send the user here after logging out
           */
          $this-Auth-logoutRedirect = array('controller' = 'users',
  'action' = 'login');
          /*
           * Send the user here after logging in.
           */
          $this-Auth-loginRedirect = array('controller' = 'main',
  'action' = 'index');
      }

  Here are the login() and logout() methods for my users_controller

      function login()
      {
          if ($this-Session-read('Auth.User'))
          {

              $this-Session-setFlash('You are logged in!');
              $this-redirect($this-Auth-loginRedirect, null, false);
          }
      }

      function logout()
      {

          exit('WTF');

          $this-Session-setFlash('Good-Bye');
          $this-redirect($this-Auth-logout());
      }

  I expect if I enter:http://swright-dev.epic-cake/users/logoutIwould
  see WTF on the screen. I get redirected.

  This is what I see repeated in my Apache access_log:
  172.27.3.23 - - [06/Dec/2011:11:12:58 -0500] GET / HTTP/1.1 302 1
  - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101
  Firefox/5.0

  Nothing is generated in the Apache error_log, or Cake's error and
  debug logs.

  The only way the redirect loop stops is if I uncomment this line in
  the beforeFilter:
  //$this-Auth-allow(array('*'));
  But then no Auth works obviously. Can someone please point me in the
  right direction?

  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: Shared code for Models but not in AppModel

2011-12-07 Thread RhythmicDevil
Guess I was right about sub classing with Cake.






On Dec 6, 9:34 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Ok so I tried extending the AppModel class to a third level sub class
 but Cake fails to find it. Perhaps you can clue me in to where I am
 going wrong.

 I have the following file structure:

 Models/
     AppModel
     GtiApi
     Solidcore

 Here are what the class files contain:

 class AppModel extends Model
 {
     public function __construct()
     {
         parent::__construct();
     }

 }

 class GtiApi extends AppModel
 {

     public $useDbConfig = 'gti';
     public $useTable = false;

     public function __construct()
     {
         parent::__construct();
     }

     // Some custom functions here that I did not paste due to space
 for this post

 }

 class Solidcore extends GtiApi
 {

     public function __construct()
     {
         parent::__construct();
     }

 }

 This is the error that I get when I attempt to load a 
 page:http://swright-dev.epic-cake/solidcores/performance

 Fatal error: Class 'GtiApi' not found in /var/www/html/epic-cake/app/
 models/solidcore.php on line 4

 So that means to me that Cake's autoloaders dont expect more than one
 level of subclass for AppModel. How do I get around that?

 On Dec 5, 4:04 pm, Miles J mileswjohn...@gmail.com wrote:







  Cake simply has trouble when trying to merge properties in one class
  with the AppClass. This should only be a problem with the
  AppController since you aren't defining many properties in AppModel.

  On Dec 5, 12:34 pm, RhythmicDevil rhythmicde...@gmail.com wrote:

   Yeah I had thought, and now have to go and check, that you could never
   extend passed one sub class from AppModel or AppController for that
   matter. I always thought that was odd but had something to do with
   cake's auto loaders. Thanks for the clue, I will check this out.

   On Dec 5, 3:11 pm, Miles J mileswjohn...@gmail.com wrote:

Are you referring to where the files go?

You can do anything in Cake that PHP allows, so extend as many times
as you please.

On Dec 5, 11:54 am, RhythmicDevil rhythmicde...@gmail.com wrote:

 Hi Miles,
 thanks for the response. Yeah I think that would be the number 3
 option I Iisted.

 The thing is how would I do the following:

 AppModel
     DbBaseModel
          SomeModel
     ApiBaseModel
          AnotheModel

 To the best of my knowledge you can actually build that kind of
 heirarchy in Cake right?

 On Dec 5, 2:49 pm, Miles J mileswjohn...@gmail.com wrote:

  You could always just create 2 base models?

  class ApiBaseModel extends AppModel {}
  class DbBaseModel extends AppModel {}

  They both would extend AppModel to gain shared functionality and 
  then
  both would have their own functionality. Cake IS PHP, so you can do
  whatever you want with classes.

  class User extends DbBaseModel {}
  class News extends ApiBaseModel {}

  -Miles

  On Dec 5, 11:29 am, RhythmicDevil rhythmicde...@gmail.com wrote:

   My application has two datasources. I use one to talk to MySQL for
   ACL. The other is a custom datasource that talks an API my 
   company is
   developing. There are about 15 models that use the custom 
   datasource
   and will probably be more. For each of those models I need to 
   share
   methods and  properties but DO NOT want the ACL models to have 
   them so
   they cannot go into AppModel.

   The reason I have many models for the API is that I want the data
   structures returned by the Model to have the correct naming. I 
   suppose
   I could set the name on the fly but for now I am curious how to 
   solve
   this other problem.

   Do behaviors solve this problem? I did not think that was really 
   their
   function. These are the properties and methods I need shared and 
   it
   has to do with how the datasource works.

       public $useDbConfig = 'gti';
       public $useTable = false;

       public function __construct()
       {
           parent::__construct();
       }

       /**
        * Overridden paginate method - group by week, away_team_id 
   and
   home_team_id
        */
       function paginate($conditions, $fields, $order, $limit, $page 
   = 1,
   $recursive = null, $extra = array())
       {
           //var_dump($conditions, $fields, $order, $limit, $page,
   $recursive, $extra);
           $recursive = -1;
           //$group = $fields = array('week', 'away_team_id',
   'home_team_id');
           return $this-find('all', compact('conditions', 'fields',
   'order', 'limit', 'page', 'recursive'));
       }

       /**
        * Overridden paginateCount method
        */
       function paginateCount($conditions = null, $recursive = 0

Re: Shared code for Models but not in AppModel

2011-12-07 Thread RhythmicDevil
No actually. I created the file and class structure as shown above. I
get an error from PHP saying class not found. So unless I have to add
includes or requires to my files Cake does not load the classes.

So Cake handles this just fine:

AppModel-SubClass
AppMode-AnotherSubClass

But not this

AppModel-SubClass-AnotherSubClass

If I am wrong about this please tell me where I am going wrong. Please
see my example above.

Thank you.



On Dec 7, 8:55 am, AD7six andydawso...@gmail.com wrote:
 On Dec 7, 1:55 pm, RhythmicDevil rhythmicde...@gmail.com wrote:

  Guess I was right about sub classing with Cake.

 what was your guess - that they work exactly the same way as the
 language itself?

-- 
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: Shared code for Models but not in AppModel

2011-12-07 Thread RhythmicDevil
Thanks man. I dont actually expect magic. Although Cake does do some
things magically, I am never sure where the magic ends and my
ignorance begins. In all my searching I never actually found a
document that stated what you did. I realized that I could load the
classes but was not sure if I was somehow stepping around the
framework. I always try to do things in the Cake way if at all
possible.



On Dec 7, 9:22 am, AD7six andydawso...@gmail.com wrote:
 On Dec 7, 3:11 pm, RhythmicDevil rhythmicde...@gmail.com wrote:

  No actually. I created the file and class structure as shown above. I
  get an error from PHP saying class not found. So unless I have to add
  includes or requires to my files Cake does not load the classes.

 well, yes. since Cake is just php, and that's how php works.



  So Cake handles this just fine:

  AppModel-SubClass
  AppMode-AnotherSubClass

 It handles that case automatically.



  But not this

  AppModel-SubClass-AnotherSubClass

 It does not handle that case automatically - it does however handle it
 'fine'.



  If I am wrong about this please tell me where I am going wrong. Please
  see my example above.

 CakePHP isn't magic. It does somethings for you automagically. If
 you're using 1.3 you must load the classes before you use them, if
 you're using 2.0 you must declare you are going to use them before
 using them.

 the only thing cake does for you (in 1.3) is automatically load App
 classes for you. In 2.0 it doesn't do that any more 
 seehttps://github.com/cakephp/cakephp/blob/master/lib/Cake/Model/AppMode...
 But you aren't talking about App classes - you're talking about some
 other classes, and you need to load/use the classes before you can
 reference them.

 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: Shared code for Models but not in AppModel

2011-12-07 Thread RhythmicDevil
Well the basic idea is that the application uses two datasources. One
is the MySQL one the other is a custom one I wrote for our API. The
Models that use the custom datasource require some methods and
properties, I posted those in the initial question on this thread.
Normally I would just put those in AppModel and be done with it. But,
they break the models that use MySQL so AppModel is not the
appropriate place.

So what I wanted to do was have AppModel at the top of the chain
containing all common Model code. Then extend that to GtiApi, User,
and Group. GtiApi would contain the methods and properties I
mentioned. Then API driven Models like Solidcore would extend GtiApi.
This now works.

In reality though I actually dont need the Solidcore models, I could
really just use GtiApi model and then do something fancy so that Model
data was under the right index, say  Solidcore. That way the
controller and views would work properly as well. Currently the Models
that extend GtiApi are empty. There may be a case for doing some extra
Model work in some of them, but I dont have all the requirements yet.



On Dec 7, 11:19 am, Geoff Douglas drdouglas...@gmail.com wrote:
 Where are you trying to use the Solidcore Model?

 I have done what you are explaining several times. Generally to apply
 different relationships to the same models, for better performance, and
 cleaner code.

 It is possible. And it is not breaking the Cake way to do it either. Cake
 is very versatile, especially with how models work.

 Let me know.

-- 
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: Shared code for Models but not in AppModel

2011-12-06 Thread RhythmicDevil
Ok so I tried extending the AppModel class to a third level sub class
but Cake fails to find it. Perhaps you can clue me in to where I am
going wrong.

I have the following file structure:

Models/
AppModel
GtiApi
Solidcore


Here are what the class files contain:

class AppModel extends Model
{
public function __construct()
{
parent::__construct();
}
}



class GtiApi extends AppModel
{

public $useDbConfig = 'gti';
public $useTable = false;

public function __construct()
{
parent::__construct();
}

// Some custom functions here that I did not paste due to space
for this post

}



class Solidcore extends GtiApi
{

public function __construct()
{
parent::__construct();
}

}

This is the error that I get when I attempt to load a page:
http://swright-dev.epic-cake/solidcores/performance


Fatal error: Class 'GtiApi' not found in /var/www/html/epic-cake/app/
models/solidcore.php on line 4




So that means to me that Cake's autoloaders dont expect more than one
level of subclass for AppModel. How do I get around that?




On Dec 5, 4:04 pm, Miles J mileswjohn...@gmail.com wrote:
 Cake simply has trouble when trying to merge properties in one class
 with the AppClass. This should only be a problem with the
 AppController since you aren't defining many properties in AppModel.

 On Dec 5, 12:34 pm, RhythmicDevil rhythmicde...@gmail.com wrote:







  Yeah I had thought, and now have to go and check, that you could never
  extend passed one sub class from AppModel or AppController for that
  matter. I always thought that was odd but had something to do with
  cake's auto loaders. Thanks for the clue, I will check this out.

  On Dec 5, 3:11 pm, Miles J mileswjohn...@gmail.com wrote:

   Are you referring to where the files go?

   You can do anything in Cake that PHP allows, so extend as many times
   as you please.

   On Dec 5, 11:54 am, RhythmicDevil rhythmicde...@gmail.com wrote:

Hi Miles,
thanks for the response. Yeah I think that would be the number 3
option I Iisted.

The thing is how would I do the following:

AppModel
    DbBaseModel
         SomeModel
    ApiBaseModel
         AnotheModel

To the best of my knowledge you can actually build that kind of
heirarchy in Cake right?

On Dec 5, 2:49 pm, Miles J mileswjohn...@gmail.com wrote:

 You could always just create 2 base models?

 class ApiBaseModel extends AppModel {}
 class DbBaseModel extends AppModel {}

 They both would extend AppModel to gain shared functionality and then
 both would have their own functionality. Cake IS PHP, so you can do
 whatever you want with classes.

 class User extends DbBaseModel {}
 class News extends ApiBaseModel {}

 -Miles

 On Dec 5, 11:29 am, RhythmicDevil rhythmicde...@gmail.com wrote:

  My application has two datasources. I use one to talk to MySQL for
  ACL. The other is a custom datasource that talks an API my company 
  is
  developing. There are about 15 models that use the custom datasource
  and will probably be more. For each of those models I need to share
  methods and  properties but DO NOT want the ACL models to have them 
  so
  they cannot go into AppModel.

  The reason I have many models for the API is that I want the data
  structures returned by the Model to have the correct naming. I 
  suppose
  I could set the name on the fly but for now I am curious how to 
  solve
  this other problem.

  Do behaviors solve this problem? I did not think that was really 
  their
  function. These are the properties and methods I need shared and it
  has to do with how the datasource works.

      public $useDbConfig = 'gti';
      public $useTable = false;

      public function __construct()
      {
          parent::__construct();
      }

      /**
       * Overridden paginate method - group by week, away_team_id and
  home_team_id
       */
      function paginate($conditions, $fields, $order, $limit, $page = 
  1,
  $recursive = null, $extra = array())
      {
          //var_dump($conditions, $fields, $order, $limit, $page,
  $recursive, $extra);
          $recursive = -1;
          //$group = $fields = array('week', 'away_team_id',
  'home_team_id');
          return $this-find('all', compact('conditions', 'fields',
  'order', 'limit', 'page', 'recursive'));
      }

      /**
       * Overridden paginateCount method
       */
      function paginateCount($conditions = null, $recursive = 0, 
  $extra
  = array())
      {
          //var_dump($conditions, $recursive, $extra);
          return 1000;
          $sql = SELECT DISTINCT ON(week, home_team_id, away_team_id)
  week, home_team_id, away_team_id FROM games

ACL + Auth = Headache

2011-12-06 Thread RhythmicDevil
I followed the instructions here: 
http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application
to learn how to setup ACL and Auth. My two test attempts went smoothly
and worked as expected. However, now that I am trying it for real its
failing. I get stuck in this redirect loop and I dont understand why.
No matter what valid URL I enter, I get a redirect loop.

This is the beforeFilter in my AppController:

function beforeFilter()
{
parent::beforeFilter();

//$this-Auth-allow(array('*'));

//Configure AuthComponent
$this-Auth-authorize = 'actions';
/*
 * If the user did not select a controller/action before
logging in, then
 * this controller/action willbe executed.
 */
$this-Auth-loginAction = array('controller' = 'users',
'action' = 'login');
/*
 * Send the user here after logging out
 */
$this-Auth-logoutRedirect = array('controller' = 'users',
'action' = 'login');
/*
 * Send the user here after logging in.
 */
$this-Auth-loginRedirect = array('controller' = 'main',
'action' = 'index');
}


Here are the login() and logout() methods for my users_controller

function login()
{
if ($this-Session-read('Auth.User'))
{

$this-Session-setFlash('You are logged in!');
$this-redirect($this-Auth-loginRedirect, null, false);
}
}

function logout()
{

exit('WTF');

$this-Session-setFlash('Good-Bye');
$this-redirect($this-Auth-logout());
}


I expect if I enter: http://swright-dev.epic-cake/users/logout I would
see WTF on the screen. I get redirected.

This is what I see repeated in my Apache access_log:
172.27.3.23 - - [06/Dec/2011:11:12:58 -0500] GET / HTTP/1.1 302 1
- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101
Firefox/5.0


Nothing is generated in the Apache error_log, or Cake's error and
debug logs.


The only way the redirect loop stops is if I uncomment this line in
the beforeFilter:
//$this-Auth-allow(array('*'));
But then no Auth works obviously. Can someone please point me in the
right direction?

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: ACL + Auth = Headache

2011-12-06 Thread RhythmicDevil
Ok so it seems that this might be the culprit:

$this-Auth-authorize = 'actions';


If I comment out that line I dont get the redirect loop.



On Dec 6, 11:21 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 I followed the instructions 
 here:http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application
 to learn how to setup ACL and Auth. My two test attempts went smoothly
 and worked as expected. However, now that I am trying it for real its
 failing. I get stuck in this redirect loop and I dont understand why.
 No matter what valid URL I enter, I get a redirect loop.

 This is the beforeFilter in my AppController:

     function beforeFilter()
     {
         parent::beforeFilter();

         //$this-Auth-allow(array('*'));

         //Configure AuthComponent
         $this-Auth-authorize = 'actions';
         /*
          * If the user did not select a controller/action before
 logging in, then
          * this controller/action willbe executed.
          */
         $this-Auth-loginAction = array('controller' = 'users',
 'action' = 'login');
         /*
          * Send the user here after logging out
          */
         $this-Auth-logoutRedirect = array('controller' = 'users',
 'action' = 'login');
         /*
          * Send the user here after logging in.
          */
         $this-Auth-loginRedirect = array('controller' = 'main',
 'action' = 'index');
     }

 Here are the login() and logout() methods for my users_controller

     function login()
     {
         if ($this-Session-read('Auth.User'))
         {

             $this-Session-setFlash('You are logged in!');
             $this-redirect($this-Auth-loginRedirect, null, false);
         }
     }

     function logout()
     {

         exit('WTF');

         $this-Session-setFlash('Good-Bye');
         $this-redirect($this-Auth-logout());
     }

 I expect if I enter:http://swright-dev.epic-cake/users/logoutI would
 see WTF on the screen. I get redirected.

 This is what I see repeated in my Apache access_log:
 172.27.3.23 - - [06/Dec/2011:11:12:58 -0500] GET / HTTP/1.1 302 1
 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101
 Firefox/5.0

 Nothing is generated in the Apache error_log, or Cake's error and
 debug logs.

 The only way the redirect loop stops is if I uncomment this line in
 the beforeFilter:
 //$this-Auth-allow(array('*'));
 But then no Auth works obviously. Can someone please point me in the
 right direction?

 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


Shared code for Models but not in AppModel

2011-12-05 Thread RhythmicDevil
My application has two datasources. I use one to talk to MySQL for
ACL. The other is a custom datasource that talks an API my company is
developing. There are about 15 models that use the custom datasource
and will probably be more. For each of those models I need to share
methods and  properties but DO NOT want the ACL models to have them so
they cannot go into AppModel.

The reason I have many models for the API is that I want the data
structures returned by the Model to have the correct naming. I suppose
I could set the name on the fly but for now I am curious how to solve
this other problem.

Do behaviors solve this problem? I did not think that was really their
function. These are the properties and methods I need shared and it
has to do with how the datasource works.

public $useDbConfig = 'gti';
public $useTable = false;

public function __construct()
{
parent::__construct();
}

/**
 * Overridden paginate method - group by week, away_team_id and
home_team_id
 */
function paginate($conditions, $fields, $order, $limit, $page = 1,
$recursive = null, $extra = array())
{
//var_dump($conditions, $fields, $order, $limit, $page,
$recursive, $extra);
$recursive = -1;
//$group = $fields = array('week', 'away_team_id',
'home_team_id');
return $this-find('all', compact('conditions', 'fields',
'order', 'limit', 'page', 'recursive'));
}

/**
 * Overridden paginateCount method
 */
function paginateCount($conditions = null, $recursive = 0, $extra
= array())
{
//var_dump($conditions, $recursive, $extra);
return 1000;
$sql = SELECT DISTINCT ON(week, home_team_id, away_team_id)
week, home_team_id, away_team_id FROM games;
$this-recursive = $recursive;
$results = $this-query($sql);
return count($results);
}


I see the following options:

1. Place the code in the AppModel file and then do some work every
time those methods and properties are needed to decide whether I use
these or the other. That seems like a lot of work.

2. Duplicate the code in each model

3. Use one model for the API and then just set it's name so that my
data structures are named correctly.

And again, behavior? Probably not, but figured I'd ask one more time.

Thanks for any advice.

-- 
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: Shared code for Models but not in AppModel

2011-12-05 Thread RhythmicDevil
Hi Miles,
thanks for the response. Yeah I think that would be the number 3
option I Iisted.

The thing is how would I do the following:

AppModel
DbBaseModel
 SomeModel
ApiBaseModel
 AnotheModel

To the best of my knowledge you can actually build that kind of
heirarchy in Cake right?




On Dec 5, 2:49 pm, Miles J mileswjohn...@gmail.com wrote:
 You could always just create 2 base models?

 class ApiBaseModel extends AppModel {}
 class DbBaseModel extends AppModel {}

 They both would extend AppModel to gain shared functionality and then
 both would have their own functionality. Cake IS PHP, so you can do
 whatever you want with classes.

 class User extends DbBaseModel {}
 class News extends ApiBaseModel {}

 -Miles

 On Dec 5, 11:29 am, RhythmicDevil rhythmicde...@gmail.com wrote:







  My application has two datasources. I use one to talk to MySQL for
  ACL. The other is a custom datasource that talks an API my company is
  developing. There are about 15 models that use the custom datasource
  and will probably be more. For each of those models I need to share
  methods and  properties but DO NOT want the ACL models to have them so
  they cannot go into AppModel.

  The reason I have many models for the API is that I want the data
  structures returned by the Model to have the correct naming. I suppose
  I could set the name on the fly but for now I am curious how to solve
  this other problem.

  Do behaviors solve this problem? I did not think that was really their
  function. These are the properties and methods I need shared and it
  has to do with how the datasource works.

      public $useDbConfig = 'gti';
      public $useTable = false;

      public function __construct()
      {
          parent::__construct();
      }

      /**
       * Overridden paginate method - group by week, away_team_id and
  home_team_id
       */
      function paginate($conditions, $fields, $order, $limit, $page = 1,
  $recursive = null, $extra = array())
      {
          //var_dump($conditions, $fields, $order, $limit, $page,
  $recursive, $extra);
          $recursive = -1;
          //$group = $fields = array('week', 'away_team_id',
  'home_team_id');
          return $this-find('all', compact('conditions', 'fields',
  'order', 'limit', 'page', 'recursive'));
      }

      /**
       * Overridden paginateCount method
       */
      function paginateCount($conditions = null, $recursive = 0, $extra
  = array())
      {
          //var_dump($conditions, $recursive, $extra);
          return 1000;
          $sql = SELECT DISTINCT ON(week, home_team_id, away_team_id)
  week, home_team_id, away_team_id FROM games;
          $this-recursive = $recursive;
          $results = $this-query($sql);
          return count($results);
      }

  I see the following options:

  1. Place the code in the AppModel file and then do some work every
  time those methods and properties are needed to decide whether I use
  these or the other. That seems like a lot of work.

  2. Duplicate the code in each model

  3. Use one model for the API and then just set it's name so that my
  data structures are named correctly.

  And again, behavior? Probably not, but figured I'd ask one more time.

  Thanks for any advice.

-- 
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: Shared code for Models but not in AppModel

2011-12-05 Thread RhythmicDevil
Yeah I had thought, and now have to go and check, that you could never
extend passed one sub class from AppModel or AppController for that
matter. I always thought that was odd but had something to do with
cake's auto loaders. Thanks for the clue, I will check this out.


On Dec 5, 3:11 pm, Miles J mileswjohn...@gmail.com wrote:
 Are you referring to where the files go?

 You can do anything in Cake that PHP allows, so extend as many times
 as you please.

 On Dec 5, 11:54 am, RhythmicDevil rhythmicde...@gmail.com wrote:







  Hi Miles,
  thanks for the response. Yeah I think that would be the number 3
  option I Iisted.

  The thing is how would I do the following:

  AppModel
      DbBaseModel
           SomeModel
      ApiBaseModel
           AnotheModel

  To the best of my knowledge you can actually build that kind of
  heirarchy in Cake right?

  On Dec 5, 2:49 pm, Miles J mileswjohn...@gmail.com wrote:

   You could always just create 2 base models?

   class ApiBaseModel extends AppModel {}
   class DbBaseModel extends AppModel {}

   They both would extend AppModel to gain shared functionality and then
   both would have their own functionality. Cake IS PHP, so you can do
   whatever you want with classes.

   class User extends DbBaseModel {}
   class News extends ApiBaseModel {}

   -Miles

   On Dec 5, 11:29 am, RhythmicDevil rhythmicde...@gmail.com wrote:

My application has two datasources. I use one to talk to MySQL for
ACL. The other is a custom datasource that talks an API my company is
developing. There are about 15 models that use the custom datasource
and will probably be more. For each of those models I need to share
methods and  properties but DO NOT want the ACL models to have them so
they cannot go into AppModel.

The reason I have many models for the API is that I want the data
structures returned by the Model to have the correct naming. I suppose
I could set the name on the fly but for now I am curious how to solve
this other problem.

Do behaviors solve this problem? I did not think that was really their
function. These are the properties and methods I need shared and it
has to do with how the datasource works.

    public $useDbConfig = 'gti';
    public $useTable = false;

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Overridden paginate method - group by week, away_team_id and
home_team_id
     */
    function paginate($conditions, $fields, $order, $limit, $page = 1,
$recursive = null, $extra = array())
    {
        //var_dump($conditions, $fields, $order, $limit, $page,
$recursive, $extra);
        $recursive = -1;
        //$group = $fields = array('week', 'away_team_id',
'home_team_id');
        return $this-find('all', compact('conditions', 'fields',
'order', 'limit', 'page', 'recursive'));
    }

    /**
     * Overridden paginateCount method
     */
    function paginateCount($conditions = null, $recursive = 0, $extra
= array())
    {
        //var_dump($conditions, $recursive, $extra);
        return 1000;
        $sql = SELECT DISTINCT ON(week, home_team_id, away_team_id)
week, home_team_id, away_team_id FROM games;
        $this-recursive = $recursive;
        $results = $this-query($sql);
        return count($results);
    }

I see the following options:

1. Place the code in the AppModel file and then do some work every
time those methods and properties are needed to decide whether I use
these or the other. That seems like a lot of work.

2. Duplicate the code in each model

3. Use one model for the API and then just set it's name so that my
data structures are named correctly.

And again, behavior? Probably not, but figured I'd ask one more time.

Thanks for any advice.

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


Order of method execution when deleting records

2011-11-16 Thread RhythmicDevil
I am writing a custom datasource. I was implementing the delete action
in the datasource and ran into a problem. I expected that when I call
Model::delete($id, false); it would execute the Datasource::delete()
method. But that does not happen. First a method called calculate() is
executed and then Datasource::read() is executed. I dont know why.

1. So why does the calculate() method get called and how do I prevent
that as it makes no sense my implementation.

2. Why does the read() method get called before delete() and how do I
prevent that?

3. Is there a document somewhere that lists the methods called in
order of execution for CRUD operations?

-- 
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: Order of method execution when deleting records

2011-11-16 Thread RhythmicDevil
For reference here is my Datasource file.


?php

App::uses('HttpSocket', 'Network/Http');

class GtiSource extends DataSource
{

/**
 * The description of this data source
 *
 * @var string
 */
public $description = 'Datasource to interact with the GTI API';

/**
 * Instance of CakePHP core HttpSocket class
 *
 * @var HttpSocket
 */
public $Http = null;

/**
 * A URL encoded JSON string
 * @var String
 */
public $queryString;
public $queryData;

/**
 * Loads HttpSocket class
 *
 * @param array $config
 * @param HttpSocket $Http
 */
public function __construct($config, $Http = null)
{
parent::__construct($config);
if (!$Http)
{
$Http = new HttpSocket();
}
$this-Http = $Http;
}

public function describe($model)
{
return $this-description;
}

public function listSources()
{
}

/**
 *
 * @param AppModel $model
 * @param array $queryData
 */
public function create($model, $fields = array(), $values =
array())
{
// Set the mode @TODO is this the right mode?
$queryData['fields']['mode'] = 'insert';
exit('DONT KNOW HOW TO CREATE A RECORD');
return $this-request();
}

/**
 *
 * @param AppModel $model
 * @param array $queryData
 */
public function read($model, $queryData = array())
{
// Set the mode
$queryData['fields']['mode'] = 'read';
$this-queryData = $queryData;
$this-model = $model;

return $this-request();
}

/**
 *
 * @param AppModel $model
 * @param array $queryData
 */
public function update($model, $fields = array(), $values =
array())
{
// Set the mode @TODO is this the right mode?
$queryData['fields']['mode'] = 'update';

exit('DONT KNOW HOW TO UPDATE A RECORD');
return $this-request();
}

/**
 *
 * @param AppModel $model
 * @param array $queryData
 */
public function delete($model, $id = null)
{
var_dump(__METHOD__);
// Deleting not allowed in the GTI API
$data = array();
// Decode the data and cast the beeatch to an Array
$data[$this-model-name] = array('Deleting is not allowed
through the GTI API');
return $data;
}

/**
 *  Does the actual request. Creates the URI from the DB config
vars and the
 *  user paramters if any.
 *
 * @param CakeModel $model
 * @return boolean
 */
public function request()
{
/*
 * The GTI API requires a key. This is set in the dbConfig
 */
if (empty($this-config['key']))
{
return false; // @TODO throw exception instead.
}
$this-queryData['fields']['key'] = $this-config['key'];

/*
 * If the request has not specified a mode then the default is
read
 */
if (empty($this-queryData['fields']['mode']))
{
$this-queryData['fields']['mode'] = 'read';
}

/*
 * If the request has not specified a cache setting then use
the default
 * from dbConfig
 */
if (empty($this-queryData['fields']['cache']))
{
$this-queryData['fields']['cache'] = $this-
config['cache'];
}

/**
 * Create the full URI include the query string because I dont
know how
 * to get Cake's HttpSocket to accept it any other way. This
works for now
 * but should be reviewed at some point.
 */
$uri = $this-config['url'] . ':' . $this-config['port'] .
'/' . urlencode(json_encode($this-queryData['fields']));
/**
 * New Socket
 */
$HttpSocket = new HttpSocket();
/*
 * Get the results
 */
$results = $HttpSocket-get($uri);
/**
 * If the returned HTTP status code is anything other than 200
then
 * something went wrong.
 */
if ($results-code == '200')
{
$data = array();
// Decode the data and cast the beeatch to an Array
$data[$this-model-name] = (Array)
json_decode($results['body']);
return $data;
}
else
{
// @TODO Where is error data supposed to go in the Model?
$model-data = json_decode($results);
return false;
}
}

public function calculate($model, $func, $params = array())
{
//var_dump(__METHOD__);
//var_dump($model, $func, $params);
return 1;
}

}

?



On Nov 16, 9:24 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 I am writing a custom datasource. I was implementing the delete action
 in the datasource and ran into a problem. I expected that when I call
 Model::delete($id, false); it would execute the Datasource::delete

Re: Order of method execution when deleting records

2011-11-16 Thread RhythmicDevil
I am using this doc as a reference: 
http://book.cakephp.org/2.0/en/models/datasources.html

It says that I must do the following which I did so I am confused by
the results.

Methods that must be implemented

describe($model)
listSources()
At least one of:
create($model, $fields = array(), $values = array())
read($model, $queryData = array())
update($model, $fields = array(), $values = array())
delete($model, $id = null)




On Nov 16, 9:29 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 For reference here is my Datasource file.

 ?php

 App::uses('HttpSocket', 'Network/Http');

 class GtiSource extends DataSource
 {

     /**
      * The description of this data source
      *
      * @var string
      */
     public $description = 'Datasource to interact with the GTI API';

     /**
      * Instance of CakePHP core HttpSocket class
      *
      * @var HttpSocket
      */
     public $Http = null;

     /**
      * A URL encoded JSON string
      * @var String
      */
     public $queryString;
     public $queryData;

     /**
      * Loads HttpSocket class
      *
      * @param array $config
      * @param HttpSocket $Http
      */
     public function __construct($config, $Http = null)
     {
         parent::__construct($config);
         if (!$Http)
         {
             $Http = new HttpSocket();
         }
         $this-Http = $Http;
     }

     public function describe($model)
     {
         return $this-description;
     }

     public function listSources()
     {
     }

     /**
      *
      * @param AppModel $model
      * @param array $queryData
      */
     public function create($model, $fields = array(), $values =
 array())
     {
         // Set the mode @TODO is this the right mode?
         $queryData['fields']['mode'] = 'insert';
         exit('DONT KNOW HOW TO CREATE A RECORD');
         return $this-request();
     }

     /**
      *
      * @param AppModel $model
      * @param array $queryData
      */
     public function read($model, $queryData = array())
     {
         // Set the mode
         $queryData['fields']['mode'] = 'read';
         $this-queryData = $queryData;
         $this-model = $model;

         return $this-request();
     }

     /**
      *
      * @param AppModel $model
      * @param array $queryData
      */
     public function update($model, $fields = array(), $values =
 array())
     {
         // Set the mode @TODO is this the right mode?
         $queryData['fields']['mode'] = 'update';

         exit('DONT KNOW HOW TO UPDATE A RECORD');
         return $this-request();
     }

     /**
      *
      * @param AppModel $model
      * @param array $queryData
      */
     public function delete($model, $id = null)
     {
         var_dump(__METHOD__);
         // Deleting not allowed in the GTI API
         $data = array();
         // Decode the data and cast the beeatch to an Array
         $data[$this-model-name] = array('Deleting is not allowed
 through the GTI API');
         return $data;
     }

     /**
      *  Does the actual request. Creates the URI from the DB config
 vars and the
      *  user paramters if any.
      *
      * @param CakeModel $model
      * @return boolean
      */
     public function request()
     {
         /*
          * The GTI API requires a key. This is set in the dbConfig
          */
         if (empty($this-config['key']))
         {
             return false; // @TODO throw exception instead.
         }
         $this-queryData['fields']['key'] = $this-config['key'];

         /*
          * If the request has not specified a mode then the default is
 read
          */
         if (empty($this-queryData['fields']['mode']))
         {
             $this-queryData['fields']['mode'] = 'read';
         }

         /*
          * If the request has not specified a cache setting then use
 the default
          * from dbConfig
          */
         if (empty($this-queryData['fields']['cache']))
         {
             $this-queryData['fields']['cache'] = $this-config['cache'];

         }

         /**
          * Create the full URI include the query string because I dont
 know how
          * to get Cake's HttpSocket to accept it any other way. This
 works for now
          * but should be reviewed at some point.
          */
         $uri = $this-config['url'] . ':' . $this-config['port'] .
 '/' . urlencode(json_encode($this-queryData['fields']));
         /**
          * New Socket
          */
         $HttpSocket = new HttpSocket();
         /*
          * Get the results
          */
         $results = $HttpSocket-get($uri);
         /**
          * If the returned HTTP status code is anything other than 200
 then
          * something went wrong.
          */
         if ($results-code == '200')
         {
             $data = array();
             // Decode the data and cast the beeatch to an Array
             $data[$this-model-name] = (Array)
 json_decode($results['body

Re: Order of method execution when deleting records

2011-11-16 Thread RhythmicDevil
thanks for the tips man, I appreciate it.

I will never have to do cascades or anything like that. I am simply
creating a JSON string to be sent to our API. The API will take care
all the Database stuff. In reality the model and datasource are pass
throughs that do some formatting for the API.



On Nov 16, 9:49 am, AD7six andydawso...@gmail.com wrote:
 On Wednesday, 16 November 2011 15:24:14 UTC+1, RhythmicDevil wrote:

  I am writing a custom datasource. I was implementing the delete action
  in the datasource and ran into a problem. I expected that when I call
  Model::delete($id, false); it would execute the Datasource::delete()
  method. But that does not happen. First a method called calculate() is
  executed and then Datasource::read() is executed. I dont know why.
  1. So why does the calculate() method get called and how do I prevent
  that as it makes no sense my implementation.

 calculate is called to determine the syntax for a count.



  2. Why does the read() method get called before delete() and how do I
  prevent that?

 That's executing the count



  3. Is there a document somewhere that lists the methods called in
  order of execution for CRUD operations?

 There's no better source of info than the code 
 itself:https://github.com/cakephp/cakephp/blob/master/lib/Cake/Model/Model.p...

 the short answer to your question is the model does if (!this-exists()) {
 return false } before performing the delete, exists() simply performs a
 find count and you're focussing on the queries that generates.

 If you want to skip that, you could rig exists (in the datasource) to
 always return true - may cause you other problems that way though. Of use
 deleteAll with no cascade and no callbacks.

 I guess it would be handy if the model allowed for skipping the exists
 checks - but it doesn't.

 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: CakePHP 2.0.3 out of the oven

2011-11-15 Thread RhythmicDevil
What drove the decision to change the naming conventions?


On Nov 13, 8:28 pm, José Lorenzo jose@gmail.com wrote:
 The CakePHP core team is proud to announce the immediate availability of
 CakePHP 2.0.3 [1]. A lot has happened in the PHP world since our last
 release, this new version incorporates all needed changes needed to adapt
 to the ever evolving world of PHP frameworks.

 One of the big changes out there was PHPUnit 3.6 being marked as stable and
 becoming the default version available through the PEAR installer. This
 change caught many developers by surprise. They could not easily run
 CakePHP's built-in test suite due to the major changes in PHPUnit. We have
 made the required changes to make sure 2.0.3 runs with no issues in both
 3.5 and 3.6 versions of PHPUnit.

 A big difference people will notice when writing unit tests is that all
 output is swallowed by PHPUnit and not presented in either the web tester
 page nor in the CLI tester. To overcome this annoyance use the--debug modifier
 if you are using the CLI interface.

 The second bit of good news is the availability of PHP 5.4-rc1. We have
 taken the time to test our framework against this PHP version and fixed
 many of the few notices and issues that discovered while running our
 automated tests. If you are early jumping on the 5.4 bandwagon, you can
 consider CakePHP one of the frameworks to be running smoothly on it.

 In total, there were 66 commits and 32 issues have been resolved for 2.0.3.
 A complete list of the changes can be viewed in the changelogs page [2],
 here is a quick summary of changes that made it into 2.0.3:

    - Runs smoothly in php 5.4
    - Easier to test controllers using REST
    - Correct manipulation of boolean values in DboSource::insertMulti()
    - Full compatibility with PHPUnit 3.6
    - Fixed several minor issues with the command line bake utility
    - Fixed Content-Length calculation when there is buffered output that
    will be sent before the response body
    - Various improvements in the UpgradeShell
    - DboSource::lastAffected() now returns correct integer

 Thanks for ever-growing interest in CakePHP, we have received many pull
 requests for both the code and documentation, we are excited about the all
 the buzz we are creating with this new version, without all your
 contributions there would not be CakePHP

    - Download a packaged release [1]
    - View the changelog [2]

 Links

    - [1]http://github.com/cakephp/cakephp
    - [2]http://cakephp.org/changelogs/2.0.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


Custom Datasource

2011-11-15 Thread RhythmicDevil
Hi All,
I am having some issues understanding the naming conventions for a
custom datasource.

datasource file name: gti_api_source.php
class name GtiApiSource


Database Config

var $gti_api = array(
'driver' = 'gti_api',
'url' = 'http://swright-dev:1337/',
);


Model

public $useDbConfig = 'gti_api';
public $useTable = false;


This is giving me errors. I did a var dump in
ConnectionManager::loadDataSource to see what it was asking for. I get
this:

array
  'filename' = string 'dbo/dbo_gti_api' (length=15)
  'classname' = string 'DboGtiApi' (length=9)
  'parent' =
array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null
  'plugin' = null
array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null
Fatal Error (256): ConnectionManager::loadDataSource - Unable to
import DataSource class .DboGtiApi [CORE/cake/libs/model/
connection_manager.php, line 185


I believe the problem is that I am defining a driver so the connection
tacks on the Dbo string to my class names and then looks for a driver.
This does not exist so it dies. I removed the driver definition from
the database def:

var $gti_api = array(
'url' = 'http://swright-dev:1337/',
);

And now I get this error:

array
  'filename' = string 'dbo_source' (length=10)
  'classname' = string 'DboSource' (length=9)
  'parent' = null
  'plugin' = null

( ! ) Fatal error: Call to undefined method DboSource::connect() in /
var/www/html/_libraries/cake_1_3/cake/libs/model/datasources/
dbo_source.php on line 143

So its still apparently wrong. The examples on the Cake site
http://book.cakephp.org/view/1077/An-Example dont really speak to
this.

Does anyone know where I am going wrong?

Thanks
Steve

-- 
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: Custom Datasource

2011-11-15 Thread RhythmicDevil
So I was using the wrong model method. I was using Model::read()
instead of Model::find(). Read did not throw an error. But Find()
does.

Now I get this: Datasource class gti could not be found.


On Nov 15, 10:26 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi All,
 I am having some issues understanding the naming conventions for a
 custom datasource.

 datasource file name: gti_api_source.php
 class name GtiApiSource

 Database Config

         var $gti_api = array(
             'driver' = 'gti_api',
             'url' = 'http://swright-dev:1337/',
         );

 Model

     public $useDbConfig = 'gti_api';
     public $useTable = false;

 This is giving me errors. I did a var dump in
 ConnectionManager::loadDataSource to see what it was asking for. I get
 this:

 array
   'filename' = string 'dbo/dbo_gti_api' (length=15)
   'classname' = string 'DboGtiApi' (length=9)
   'parent' =
     array
       'filename' = string 'dbo_source' (length=10)
       'classname' = string 'DboSource' (length=9)
       'parent' = null
       'plugin' = null
   'plugin' = null
 array
   'filename' = string 'dbo_source' (length=10)
   'classname' = string 'DboSource' (length=9)
   'parent' = null
   'plugin' = null
 Fatal Error (256): ConnectionManager::loadDataSource - Unable to
 import DataSource class .DboGtiApi [CORE/cake/libs/model/
 connection_manager.php, line 185

 I believe the problem is that I am defining a driver so the connection
 tacks on the Dbo string to my class names and then looks for a driver.
 This does not exist so it dies. I removed the driver definition from
 the database def:

         var $gti_api = array(
             'url' = 'http://swright-dev:1337/',
         );

 And now I get this error:

 array
   'filename' = string 'dbo_source' (length=10)
   'classname' = string 'DboSource' (length=9)
   'parent' = null
   'plugin' = null

 ( ! ) Fatal error: Call to undefined method DboSource::connect() in /
 var/www/html/_libraries/cake_1_3/cake/libs/model/datasources/
 dbo_source.php on line 143

 So its still apparently wrong. The examples on the Cake 
 sitehttp://book.cakephp.org/view/1077/An-Exampledont really speak to
 this.

 Does anyone know where I am going wrong?

 Thanks
 Steve

-- 
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: Custom Datasource

2011-11-15 Thread RhythmicDevil
I got it working finally. This is what I ended up with:

database.php

public $gti = array(
'datasource' = 'GtiSource',
'url' = 'http://swright-dev:1337/'
);


Model

public $useDbConfig = 'gti';

Datasource
filename: GtiSource.php
class : GtiSource

Although the filename: gti_source also works.





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


MySQL Password Hashing

2011-03-21 Thread RhythmicDevil
PHP: 5.3.5
Cake: 1.3.7
MySQL: 5.1.47

So if I understand it right the PHP mysql driver that cake uses does
not support the password hashes in MySQL, If this is true, what is the
proper solution given that I have a shared host and cannot enable
short passwords or user the old_passwords() function?

Is Cake going to address this?

Thanks
For any help.

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


Mapping incoming data

2011-02-11 Thread RhythmicDevil
Hi,
I am using a SOAP web service as my datasource. The data that the
model fetches from the web service is a complex object (nested arrays
and objects). I want to map this returned data to an object that my
app will use internally. There a couple of reasons for this:

1. If the names of fields in the returned data change (and they do) I
just have to fix it one place.
2. I can normalize the data set

It makes sense to me to do this in the model after the find/read
operation has completed. However I can seem to figure out how. I have
come up with the following but they seem clunky.

1. Create a bunch of Vendor classes to represent my internal data
objects and include them at run time.
2. Add a method to the model where I lay out the data object class
using StdClass and then fill the data.

Neither of those is appealing although they would solve the problem.
There must be a mechanism that cake provides for this I just cant
figure which one is appropriate.

Thanks for any advice.

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


Cake and SOAP

2011-02-11 Thread RhythmicDevil
Hi,
I have an application that uses SoapSource for one of its datasources.
The Web Service that I am using only defines one method:
sendTransaction. The data set that is sent to this method includes an
element called TransactionCommand that contains a string that
represents the actual command I want to run on the server. For
instance:

SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/
envelope/ xmlns:ns1=http://www.etisoftware.com/wsi18n;
SOAP-ENV:Bodyns1:sendTransaction
loginNamewebapp/loginName
loginPasswords0l0pw0rd/loginPassword
orgNameworks/orgName
transaction
id09-02-11-58:51:am - QueryLocale/id
wait0/wait
version3.2/version
TransactionCommandList
TransactionCommand
QueryLocale
  localeNbr1/localeNbr
   /QueryLocale
   /TransactionCommand
   /TransactionCommandList
/transaction
/ns1:sendTransaction
/SOAP-ENV:Body
/SOAP-ENV:Envelope


The method that I am actually running is QueryLocale. I used to have
one model file per web service (we have about 5 of these) and each
method in the model mapped to one of the TransactionCommands. I
recently updated SoapSource to add the extra parameters I need to
build the SOAP packet and I can use find() and read() on the models
and I dont have to map the TransactionCommands. So now my model looks
more like this:


class Epg extends AppModel
{

public $useDbConfig = 'epg_soap';
public $useTable = false;

public function find($method, $params)
{
$this-responseKeys = $params['responseKeys'];
return $this-afterFind($this-query('sendTransaction',
$params['conditions'], $method), true);
}

public function afterFind($results, $primary)
{
return $results-transactionResult-{$this-responseKeys[0]}-
{$this-responseKeys[1]};
}
}


$method is a string that represents a TransactionCommand.



Is there a better way to do this? I cannot change the Web Service. Do
you see any gotchas in what I am doing?

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


Cache

2010-07-16 Thread RhythmicDevil
Hello,
I have a view that shows a television schedule, similar to DirectTVs
(http://www.directv.com/DTVAPP/epg/theGuide.jsp). It is a list of
channels and programs in a 4 hour slice broken into 1/2 hour columns.
When the schedule first loads the start time is is the most recent 1/2
hour mark. Meaning that if its 7.03am the window will start at 7am. If
the time is 7.47am the window will start at 7.30. You are able to page
left and right in 1/2 hour chunks.

I am trying to improve performance of the view, as you can imagine its
a ton of data to compile and the HTML is fairly complex. My aim is
cache the most current schedule chunk. So assume the time is currently
7.03am. The application gets it's first request for the schedule. The
controller fetches the schedule from the model starting at 7.00am and
then caches it. All subsequent requests for that particular start time
(7am) for all users will use the cached version until 7.30am at which
point the cache is cleared and process starts again.

I have implemented Cake's view caching and set the cache action as
follows:

$this-cacheAction = array('getTvSchedule/' = 1800);

This causes an obvious problem. If the first request for a schedule
comes after a 1/2 hour mark (7am, 7.30am, 8am etc) the cache will
refreshed a half hour after that time and not at the next half hour
mark. I can do some math to figure out the remaining time and use that
to set the cache timeout.


My big problem comes when paging right and left in time. The cache
manager does not recognize that a different request has been made and
it serves the current cached version. How do I get the cache manager
to see the difference?

Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Cache

2010-07-16 Thread RhythmicDevil
Thanks for the reply.

The number of channels is variable but always more than a 100.

I would prefer not to cache in the client as I would still have to
serve up an entire days worth of the schedule for every user. I
definitely have to cache on the server. I think my best option, if I
cant get Cake to do it, is to use Memcache.

On Jul 16, 9:21 am, cricket zijn.digi...@gmail.com wrote:
 On Fri, Jul 16, 2010 at 8:44 AM, RhythmicDevil rhythmicde...@gmail.com 
 wrote:
  Hello,
  I have a view that shows a television schedule, similar to DirectTVs
  (http://www.directv.com/DTVAPP/epg/theGuide.jsp). It is a list of
  channels and programs in a 4 hour slice broken into 1/2 hour columns.
  When the schedule first loads the start time is is the most recent 1/2
  hour mark. Meaning that if its 7.03am the window will start at 7am. If
  the time is 7.47am the window will start at 7.30. You are able to page
  left and right in 1/2 hour chunks.

  I am trying to improve performance of the view, as you can imagine its
  a ton of data to compile and the HTML is fairly complex. My aim is
  cache the most current schedule chunk. So assume the time is currently
  7.03am. The application gets it's first request for the schedule. The
  controller fetches the schedule from the model starting at 7.00am and
  then caches it. All subsequent requests for that particular start time
  (7am) for all users will use the cached version until 7.30am at which
  point the cache is cleared and process starts again.

  I have implemented Cake's view caching and set the cache action as
  follows:

  $this-cacheAction = array('getTvSchedule/' = 1800);

  This causes an obvious problem. If the first request for a schedule
  comes after a 1/2 hour mark (7am, 7.30am, 8am etc) the cache will
  refreshed a half hour after that time and not at the next half hour
  mark. I can do some math to figure out the remaining time and use that
  to set the cache timeout.

  My big problem comes when paging right and left in time. The cache
  manager does not recognize that a different request has been made and
  it serves the current cached version. How do I get the cache manager
  to see the difference?

 How many channels are you working with? My first thought is to cache
 the entire day's schedule and use javascript to display only a certain
 portion. Off the top of my head, I'm not quite sure how I'd do that
 but I'll bet there's a really elegant way to do that with, say,
 jquery. I'm thinking that you'd give the table colgroups [1] IDs based
 on the time (note that IDs cannot begin with a digit so prepend some
 string to each). Then have your JS parse out the hash portion of the
 URL to figure out from where to display from.

 So, your JS would, on page load, hide the entire table, then parse the
 location.hash value (if not exists, start from the beginning of the
 table), and then slide the table colgroups to the left (obviously, use
 CSS overflow to hide what is off the screen) until the desired time
 colgroup is at the left side. Then your paging links would simply call
 a JS function to slide the schedule left or right. No reloading the
 page.

 Does that make sense?

 BTW, with Cake, you can create a link with a hash value by using the
 '#' option in $html-link().

 [1]http://www.w3.org/TR/2010/WD-html-markup-20100624/colgroup.html

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Cache

2010-07-16 Thread RhythmicDevil
Ok I get you, that makes more sense. I will look into implementing
that.

On Jul 16, 9:56 am, cricket zijn.digi...@gmail.com wrote:
 On Fri, Jul 16, 2010 at 9:37 AM, RhythmicDevil rhythmicde...@gmail.com 
 wrote:
  Thanks for the reply.

  The number of channels is variable but always more than a 100.

  I would prefer not to cache in the client as I would still have to
  serve up an entire days worth of the schedule for every user.

 I meant to cache it on the server. You'd only be serving the entire
 day on that user's first request. Any subsequent request for earlier
 or later in the schedule for that day would simply slide the table
 left or right to the correct position.

  I think my best option, if I cant get Cake to do it, is to use Memcache.

 Cake works very well with MemCache.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Cache

2010-07-16 Thread RhythmicDevil
Thank you.

On Jul 16, 10:02 am, cricket zijn.digi...@gmail.com wrote:
 On Fri, Jul 16, 2010 at 9:59 AM, RhythmicDevil rhythmicde...@gmail.com 
 wrote:
  Ok I get you, that makes more sense. I will look into implementing
  that.

 The more I think about it, the more I want to try it. I might take a
 swing at it this weekend. I'll let you know if I do and can get it to
 work.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Create association with a join table.

2010-02-08 Thread RhythmicDevil
Guess this must be impossible.

On Feb 5, 3:33 pm, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi,
 having some problems understanding how to create an association
 between two existing records. The scenario is the following. I have
 recipes and menus. When viewing a recipe I want the user to be able to
 select a menu from a list to add the recipe to. (Menus contain
 Recipes). So once again, the recipe and the list of menus already
 exist.

 When I submit the data to the Menu-save() method it complains that I
 am missing fields. This would make sense if I was creating a new menu
 and associating recipes at the same time, but I am not. All that needs
 to happen is to insert a new record into menus_recipes (join table)
 that has the recipe_id and menu_id. In concept this is simple but
 something about model associations is eluding me.

 This is the top of the recipe view file where I create a form to send
 the menu_id and the recipe_id:

 h1Recipe/h1
 div
         labelRecipe/label
         ?php
                 echo $recipe['Recipe']['recipe'];
                 $form-create('Menu', array('url'='/menus/add_recipe'));
                 echo $form-input('Recipe.recipe_id', array('value'=
 $recipe['Recipe']['id'], 'label'=false, 'type'='hidden'));
                 echo $form-input('Menu.menu_id');
                 $form-end('Add to Menu');
         ?
 /div

 Here is menus_controller add_recipe:
         public function add_recipe()
         {
                 var_dump($this-data);
                 $this-Menu-saveAll($this-data);
                 $this-Session-setFlash('The recipe has been added to the 
 menu');
             $this-redirect(array('controller'='recipes',
 'action'='index'));
         }

 I am probably going to just write a raw SQL statement to take care of
 this but I would really like to know the correct Cake methodology for
 this. I honestly have read the docs and cant find what I am looking
 for, which probably means I am looking for the wrong thing. If you are
 really interested here is a link to the source code in Google's
 project hosting:http://code.google.com/p/menurecipemanager/

 Thanks for any help or advice.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Create association with a join table.

2010-02-05 Thread RhythmicDevil
Hi,
having some problems understanding how to create an association
between two existing records. The scenario is the following. I have
recipes and menus. When viewing a recipe I want the user to be able to
select a menu from a list to add the recipe to. (Menus contain
Recipes). So once again, the recipe and the list of menus already
exist.

When I submit the data to the Menu-save() method it complains that I
am missing fields. This would make sense if I was creating a new menu
and associating recipes at the same time, but I am not. All that needs
to happen is to insert a new record into menus_recipes (join table)
that has the recipe_id and menu_id. In concept this is simple but
something about model associations is eluding me.

This is the top of the recipe view file where I create a form to send
the menu_id and the recipe_id:

h1Recipe/h1
div
labelRecipe/label
?php
echo $recipe['Recipe']['recipe'];
$form-create('Menu', array('url'='/menus/add_recipe'));
echo $form-input('Recipe.recipe_id', array('value'=
$recipe['Recipe']['id'], 'label'=false, 'type'='hidden'));
echo $form-input('Menu.menu_id');
$form-end('Add to Menu');
?
/div


Here is menus_controller add_recipe:
public function add_recipe()
{
var_dump($this-data);
$this-Menu-saveAll($this-data);
$this-Session-setFlash('The recipe has been added to the 
menu');
$this-redirect(array('controller'='recipes',
'action'='index'));
}


I am probably going to just write a raw SQL statement to take care of
this but I would really like to know the correct Cake methodology for
this. I honestly have read the docs and cant find what I am looking
for, which probably means I am looking for the wrong thing. If you are
really interested here is a link to the source code in Google's
project hosting: http://code.google.com/p/menurecipemanager/

Thanks for any help or advice.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Re: Form app_helper output

2010-01-13 Thread RhythmicDevil
Mark,
thanks for the reply. I am inclined to agree with you. I was just
experimenting with the CakePHP helpers to see what was available. I
was just very surprised at how that failed.

Thanks
Steve


On Jan 12, 4:21 pm, euromark dereurom...@googlemail.com wrote:
 actually i dont like that approach
 but i guess thats everybody's own opinion

 not without reason even the very famous flash() function now
 finally returns the values in cake1.3 instead of echoing it
 same with the debug sql table

 there might still be some cases where you have to chain the strings
 and return them to somewhere else
 this way you put a spoke in your wheel

 so better returning everything and echoing it extactly where you want
 to have it.
 there is no overhead to this at all - quite the opposite actually

 greets
 mark

 On 12 Jan., 21:21, RhythmicDevil rhythmicde...@gmail.com wrote:

  Hi,
  I did not want to type echo statements into my views so I took the
  suggestion of the CakePHP docs and added the following function to my
  app_helper:

  public function output($string)
  {
       echo parent::output($string.\n);

  }

  And I use it like this:

          ?php
                  $form-create($options = array('action' = 'login'));
                  $form-input('User.username');
                  $form-input('User.password');
                  $form-button(__('Login', true), array('type'='submit',
  'class'='ui-state-default'));
                  $form-end();
          ?

  The output looks like this:

  form id=LoginForm method=post action=/users/login
  label for=UserUsernameUsername/label
  input name=data[User][username] type=text value=
  id=UserUsername /
  div class=input text/div
  label for=UserPasswordPassword/label
  input type=password name=data[User][password] value=
  id=UserPassword /
  div class=input password/div

  input type=submit value=Login class=ui-state-default /
  /form

  Why are the inputs not inside the divs where they belong? If I remove
  the function and replace the echos for each of the form elements it
  works. Seems wrong that I can write a function so that I dont have to
  type an echo when using the helpers but then I have to manually add
  the containing div.

  One other related question. How do I accomplish using  the Html helper
  method tableCells and placing form elements in the cells? I put the
  form element method as an element of the array that is passed to the
  tableCells method I get no output.

  Any help would be appreciated.
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Form app_helper output

2010-01-12 Thread RhythmicDevil
Hi,
I did not want to type echo statements into my views so I took the
suggestion of the CakePHP docs and added the following function to my
app_helper:

public function output($string)
{
 echo parent::output($string.\n);
}

And I use it like this:

?php
$form-create($options = array('action' = 'login'));
$form-input('User.username');
$form-input('User.password');
$form-button(__('Login', true), array('type'='submit',
'class'='ui-state-default'));
$form-end();
?

The output looks like this:

form id=LoginForm method=post action=/users/login
label for=UserUsernameUsername/label
input name=data[User][username] type=text value=
id=UserUsername /
div class=input text/div
label for=UserPasswordPassword/label
input type=password name=data[User][password] value=
id=UserPassword /
div class=input password/div

input type=submit value=Login class=ui-state-default /
/form


Why are the inputs not inside the divs where they belong? If I remove
the function and replace the echos for each of the form elements it
works. Seems wrong that I can write a function so that I dont have to
type an echo when using the helpers but then I have to manually add
the containing div.

One other related question. How do I accomplish using  the Html helper
method tableCells and placing form elements in the cells? I put the
form element method as an element of the array that is passed to the
tableCells method I get no output.

Any help would be appreciated.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Non existent class method NOT throwing an error

2009-12-21 Thread RhythmicDevil
I am very confused.  If I do the following:
?php
class MyClass
{

public function mymethod()
{
print This is my method;
}

}

$cl = new MyClass();

$cl-mymethod();

$cl-no_method();
?

The call to no_method() will throw an error. However when I am using
CakePHP this does not seem to be the case.

Please consider the following:

$api_resp = $this-API-AddWorkOrder($this-Session-read
('Subscriber.SubscriberId'), CHANGE_EQUIPMENT, WO_OWNER, $devices);

The AddWorkOrder method does not exist but I get no errors or warnings
even with error reporting set to max.

What am I missing?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Session, Cache and Model

2009-11-24 Thread RhythmicDevil
I am confused as to why the Session object is only available in the
Controller. Shouldn't it be the Model's responsibility to cache the
data?

--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@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: Session, Cache and Model

2009-11-24 Thread RhythmicDevil
Thank you for the reply.

On Nov 24, 11:20 am, josu jauregui jos...@gmail.com wrote:
 Hi! In the controller you especify if you want to use cache mode(cache time,
 actions cached, ...); the Model gets the data to the controller and the
 controller process it according to the cache settings you specify in the
 controller class. More 
 info:http://book.cakephp.org/view/346/Caching-in-the-Controller

 I hope it can help you!

 2009/11/24 RhythmicDevil rhythmicde...@gmail.com

  I am confused as to why the Session object is only available in the
  Controller. Shouldn't it be the Model's responsibility to cache the
  data?

  --

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Session array keys not working

2009-11-20 Thread RhythmicDevil
I am having an issue setting data to Session. I have an array in
Session:

Devices.Staging

I want to add a device to the array using the device_id as a key. I
expect something similar to the following:

Devices.Staging.12345678901 = device
Devices.Staging.12345678902 = device

The problem is that my device_id dont seem to work with Session. I am
99% sure its because the ids start with numerals. Because device_ids
that start with an alpha character work without any problems. In
addition if I append an alpha char to the numeric ID it works.

I dont understand why this would be. I am using the device_id as a
string. I have opened up the session.php file and verified that its a
string.

$this-Session-write(Devices.Staging.$device_id,
$query_device_response-queryDeviceRsp);

Another mystery is that the key is replaced by another string of
digits. I dont know where or how this string is generated but its the
same every time.

The following method takes an array of device_id and iterates through
it. On each iteration it will attempt to pull back the device record
from the API. Then it will add the device id and device record as a
key and value respectively to Devices.Staging

public function add_devices_to_staging()
{
Logger::write($this-params['form']['device_ids']);
foreach($this-params['form']['device_ids'] as $device_id)
{
$query_device_response = 
$this-TriadApi-QueryDevice($device_id);
$this-Session-write(Devices.Staging.$device_id,
$query_device_response-queryDeviceRsp);
}

Logger::write($this-Session-read('Devices'));
$response['status'] = 'success';
$this-set('response', json_encode($response) );
$this-render('/elements/ajax_response', 'ajax');
}

As I said previously this only an issue of the key starts with
numbers. Here is the log output. Notice the array of device_ids and
the last device is the only one in Devices.Staging which means that
the mystery key '2147483647' is being used over and over.



2009-11-20 14:34:36 : Array
(
[0] = 123456789010
[1] = 123456789011
[2] = 123456789013
[3] = 123456789017
)

2009-11-20 14:34:36 : Array
(
[Staging] = Array
(
[2147483647] = stdClass Object
(
[DeviceId] = 123456789017
[DeviceBasics] = stdClass Object
(
[DeviceType] = SA Explorer
[DeviceModel] = Explorer 8300HD MR
[DeviceStatus] = Stock
[UnitAddress] =
[HostId] =
[SecurityData] =
[CustomFieldList] = stdClass Object
(
[CustomField] = Array
(
[0] = stdClass Object
(
[FieldLabel] = SA
Model
[FieldValue] =
)

[1] = stdClass Object
(
[FieldLabel] =
Room Location
[FieldValue] =
Undefined
)

)

)

)

[Location] = stdClass Object
(
[LocationId] = HEADEND 01 INVENTORY
[HeadendCode] = 01
[NetLocCode] =
[Address1] =
[Address2] =
[City] =
[State] =
[Zip] =
[CustomFieldList] = stdClass Object
(
[CustomField] = Array
(
[0] = stdClass Object
(
[FieldLabel] =
Drop Type
[FieldValue] =
)

[1] = stdClass Object
(
[FieldLabel] =
Number of Outlets
[FieldValue] =
)

  

Extending AppModel

2009-09-03 Thread RhythmicDevil

Hi,
I have an app. It has to get data from two different sources, a mysql
db and an XML API

For the API model I want to be able to do the following:

TriadAPI - extends AppModel contains generic query and connection info
Subscriber - extends TriadAPI and contains subscriber specific queries

I am also using a data source called soap_source.

The problem I have is that I dont have any idea where to put the
TriadAPI file so that it gets loaded.  The reason I want to do this is
that I dont want to repeat the generic query and connection info. It
makes senses to me that the hierarchy should look like this:

AppModel - TriadAPI - Subscriber

I cant modify AppModel as that will screw up the models that need to
use the DB. At least I think thats that would happen. I have pasted my
model classes below for reference. Thanks for any advice.

/app/models/triad_api.php
class TriadApi extends AppModel
{
/**
 * @var useDbConfig
 * @description The name of the DataSource connection that this
Model uses. Defined in core/database.php
 */
public $useDbConfig = 'soap';
public $useTable = false;

public $TransactionParams = array ();

public function __construct()
{
parent::__construct();

$api_config = Configure::read('API');

$this-TransactionParams['loginName'] = $api_config
['loginName'];
$this-TransactionParams['loginPassword'] = $api_config
['loginPassword'];
$this-TransactionParams['orgName'] = $api_config['orgName'];

$this-TransactionParams['transaction']['id'] = date('d-m-y-
i:s:a').' - ';
$this-TransactionParams['transaction']['wait'] = $api_config
['wait'];
$this-TransactionParams['transaction']['version'] =
$api_config['version'];
$this-TransactionParams['transaction']
['TransactionCommandList'] = array ();
}

public function formatResult($result)
{
return $result-transactionResult;
}

public function queryDatabase()
{
//stub
}
}


/app/models/subscriber.php
class Subscriber extends TriadApi
{
public function __construct()
{
parent::__construct();
}

public function QuerySub($SubscriberId)
{
$this-TransactionParams['transaction']['id'].'QuerySub';
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['QuerySub']
['SubscriberId'] = $SubscriberId;
return $this-formatResult($this-query('SendTransaction',
$this-TransactionParams));
}

/*
 *  QuerySubNRC
 *  SubscriberId subscriber_id /SubscriberId
 *  /QuerySubNRC
 */
public function QuerySubNRC($SubscriberId)
{
$this-TransactionParams['transaction']['id'].'QuerySubNRC';
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['QuerySubNRC']
['SubscriberId'] = $SubscriberId;
return $this-formatResult($this-query('SendTransaction', 
$this-
TransactionParams));
}


/*
 *  PerformSubOp
 *  SubscriberId subscriber_id /SubscriberId
 *  Operation operation /Operation
 *  /PerformSubOp
 */
public function PerformSubOp($SubscriberId)
{
$this-TransactionParams['transaction']['id'].'PerformSubOp';
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['PerformSubOp']
['SubscriberId'] = $SubscriberId;
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['PerformSubOp']
['Operation'] = 'Refresh';
return $this-query('SendTransaction', $this-
TransactionParams);
}
}

--~--~-~--~~~---~--~~
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: Extending AppModel

2009-09-03 Thread RhythmicDevil

Hi Mark,
thanks for taking the time to write back. However I am not entirely
sure what you mean. I tried to pass an integer to AppModel's
constructor which is called in TriadAPI's constructor but I am still
getting the same error which is:

Fatal error: Class 'TriadApi' not found in C:\vhosts\local.solowsc\app
\models\subscriber.php on line 2

This leads me to believe that triad_api.php is in the wrong location
to do what I want to do or that I am approaching this completely ass
backwards. So what is the correct way to deal with this? I suppose I
could just have one model that represents the API and place all my
methods in that. But thats going to get messy quickly as I will be
getting Subscriber data, TV Schedule data and Device data from the
API.

What is your opinion?


Thanks
Steve





On Sep 3, 2:10 pm, mark_story mark.st...@gmail.com wrote:
 You forgot all the parameters to the model constructor.

 http://api.cakephp.org/class/model#method-Model__construct

 -Mark

 On Sep 3, 11:00 am, RhythmicDevil rhythmicde...@gmail.com wrote:

  Hi,
  I have an app. It has to get data from two different sources, a mysql
  db and an XML API

  For the API model I want to be able to do the following:

  TriadAPI - extends AppModel contains generic query and connection info
  Subscriber - extends TriadAPI and contains subscriber specific queries

  I am also using a data source called soap_source.

  The problem I have is that I dont have any idea where to put the
  TriadAPI file so that it gets loaded.  The reason I want to do this is
  that I dont want to repeat the generic query and connection info. It
  makes senses to me that the hierarchy should look like this:

  AppModel - TriadAPI - Subscriber

  I cant modify AppModel as that will screw up the models that need to
  use the DB. At least I think thats that would happen. I have pasted my
  model classes below for reference. Thanks for any advice.

  /app/models/triad_api.php
  class TriadApi extends AppModel
  {
      /**
       * @var useDbConfig
       * @description     The name of the DataSource connection that this
  Model uses. Defined in core/database.php
       */
      public $useDbConfig = 'soap';
      public $useTable = false;

      public $TransactionParams = array ();

      public function __construct()
      {
          parent::__construct();

          $api_config = Configure::read('API');

          $this-TransactionParams['loginName'] = $api_config
  ['loginName'];
          $this-TransactionParams['loginPassword'] = $api_config
  ['loginPassword'];
          $this-TransactionParams['orgName'] = $api_config['orgName'];

          $this-TransactionParams['transaction']['id'] = date('d-m-y-
  i:s:a').' - ';
          $this-TransactionParams['transaction']['wait'] = $api_config
  ['wait'];
          $this-TransactionParams['transaction']['version'] =
  $api_config['version'];
          $this-TransactionParams['transaction']
  ['TransactionCommandList'] = array ();
      }

          public function formatResult($result)
          {
                  return $result-transactionResult;
          }

          public function queryDatabase()
          {
                  //stub
          }

  }

  /app/models/subscriber.php
  class Subscriber extends TriadApi
  {
      public function __construct()
      {
          parent::__construct();
      }

      public function QuerySub($SubscriberId)
      {
          $this-TransactionParams['transaction']['id'].'QuerySub';
          $this-TransactionParams['transaction']
  ['TransactionCommandList']['TransactionCommand']['QuerySub']
  ['SubscriberId'] = $SubscriberId;
          return $this-formatResult($this-query('SendTransaction',
  $this-TransactionParams));
      }

          /*
           *      QuerySubNRC
           *              SubscriberId subscriber_id /SubscriberId
           *      /QuerySubNRC
           */
          public function QuerySubNRC($SubscriberId)
          {
          $this-TransactionParams['transaction']['id'].'QuerySubNRC';
          $this-TransactionParams['transaction']
  ['TransactionCommandList']['TransactionCommand']['QuerySubNRC']
  ['SubscriberId'] = $SubscriberId;
                  return $this-formatResult($this-query('SendTransaction', 
  $this-TransactionParams));

          }

      /*
       *  PerformSubOp
       *          SubscriberId subscriber_id /SubscriberId
       *          Operation operation /Operation
       *  /PerformSubOp
       */
      public function PerformSubOp($SubscriberId)
      {
          $this-TransactionParams['transaction']['id'].'PerformSubOp';
          $this-TransactionParams['transaction']
  ['TransactionCommandList']['TransactionCommand']['PerformSubOp']
  ['SubscriberId'] = $SubscriberId;
          $this-TransactionParams['transaction']
  ['TransactionCommandList']['TransactionCommand']['PerformSubOp']
  ['Operation'] = 'Refresh';
          return $this-query('SendTransaction', $this-

  TransactionParams

Re: i18n

2009-08-19 Thread RhythmicDevil

Thanks Marcelo. I will do as you suggested.

On Aug 18, 6:38 pm, Marcelo Andrade mfandr...@gmail.com wrote:
 On Tue, Aug 18, 2009 at 12:30 PM, RhythmicDevilrhythmicde...@gmail.com 
 wrote:

 (..)
  From what I have read I gather that I wrap all my strings in my views
  with __(). Create language directories in /app/locale like the
  following:
  /app/locale/
               eng/
                    LC_MESSAGES/
                en_GB/
                    LC_MESSAGES/
  Then I go to the console and run $cakei18n. I give that the path
  where the files I want to extract reside and then give it the path
  where I want it output the files. The paths I used were:

  /home/swright/vhosts/solowsc/app/views
  /home/swright/vhosts/solowsc/app/locale

  This created a file called default.pot in the following location:
  /home/swright/vhosts/solowsc/app/locale

 You have to put the .po files into the LC_MESSAGES
 directory for each language.

  Thats about as far as I get. I have no idea what to do with the
  created file. Where do the .po and .mo files come in? Do I have to
  create them? I also would have thought that the output path should
  have been a particular language directory. I get the impression from
  what I have read that the translation and file creation is an
  automated process, is that correct?

 All you have to do to create the files is enclose youri18nstring messages 
 with the __() function.  Then,
 running cakei18nfrom console, you'll have a default
 language version .po file.  Then copy it to the other
 LC_MESSAGES language directory and make the
 translations (with poEdit or a plain text editor).

 CakePHP uses the .po files to generate (compile) the
 .mo files internally.  You don't have to deal with it.

  I have a basic test working but the files are hand created and I dont
  think thats the correct way to do it. I would really appreciate if
  someone could fill in the holes with, perhaps, a set of detailed steps
  what will work for CakePHP1.2.

 Well...  I did ani18napplication with Cake sometime
 ago and I didn't dive into problems.  It was an easy
 job.  Check this tips and read the cookboo too and
 tell us if you're still getting into problems.

 http://book.cakephp.org/view/161/Internationalization-Localization

 Best regards.

 --
 MARCELO DE F. ANDRADE
 Belem, PA, Amazonia, Brazil
 Linux User #221105

 http://mfandrade.wordpress.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
-~--~~~~--~~--~--~---



i18n

2009-08-18 Thread RhythmicDevil

Hello,
I am having some trouble understanding exactly how to use i18n. I have
tried a couple of different things and its basically working but I am
still really sketchy on the details and cannot seem to find a
definitive source on what exactly I am supposed to do.

Using CakePHP Console

From what I have read I gather that I wrap all my strings in my views
with __(). Create language directories in /app/locale like the
following:
/app/locale/
  eng/
   LC_MESSAGES/
   en_GB/
   LC_MESSAGES/
Then I go to the console and run $cake i18n. I give that the path
where the files I want to extract reside and then give it the path
where I want it output the files. The paths I used were:

/home/swright/vhosts/solowsc/app/views
/home/swright/vhosts/solowsc/app/locale

This created a file called default.pot in the following location:
/home/swright/vhosts/solowsc/app/locale

Thats about as far as I get. I have no idea what to do with the
created file. Where do the .po and .mo files come in? Do I have to
create them? I also would have thought that the output path should
have been a particular language directory. I get the impression from
what I have read that the translation and file creation is an
automated process, is that correct?

Using PoEdit
I created some files manually and edited them using PoEdit. This
created a .po and a .mo file. However I am still very unclear on the
relationships of all these moving parts.

I have a basic test working but the files are hand created and I dont
think thats the correct way to do it. I would really appreciate if
someone could fill in the holes with, perhaps, a set of detailed steps
what will work for CakePHP1.2.

Thanks
Steve

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



Internationalization

2009-08-17 Thread RhythmicDevil

Hi,
I am trying to understand how to get internationalization to work in
CakePHP. After reading the docs and searching around, looking at
Teknoid and some other place this is what I am left with.

CakePHP has a class I18n that handles the loading of the correct
string from a .po file based upon the language locale setting.

CakePHP has a console app that supposedly will read all the strings in
your view files and create language files for you.

I wrap my string ids in _() which will return the msg for that id.

I can use POEdit to create my files.


Given that. I created one message and placed it in the default.po file
for English. I then used the translator function for the heading on my
login page. However when I start the app it simply fails and tells me
that _()  is an undefined function.

Here is the content of my controller:

class SubscribersController extends Controller
{
public $helpers = array ('Form', 'Html', 'Javascript');
public $components = array ('DataPrep');

public $SubscriberId = null;

public function login()
{
$this-pageTitle = 'Please Login';
$this-layout = 'login';
$this-SubscriberId = $this-params['data']['Subscriber']
['SubscriberId'];
$this-log('Login attempt with SubscriberId: '.$this-
SubscriberId, Configure::read('APP_LOG'));
$subscriber = $this-Subscriber-QuerySub($this-
SubscriberId);
if ($subscriber-resultCode == 0)
{
$this-Session-write('Subscriber', $subscriber-
querySubRsp);
//debug($this-Session-read('Subscriber'));
$this-redirect( array ('controller'='subscribers',
'action'='basics'));
}

}


Here is the content of my View file:

div class=grid_6nbsp;/div
div class=grid_4 style=margin-top:200px; background:#FFF;
div style=text-align:center; font-weight:bold;?php 
_(Please
Login); ?/div
div style=padding:20px;

?php
echo $form-create($options = array('action' = 
'login'));
echo $form-input('Subscriber.SubscriberId');
echo $form-button('Login', array('type'='submit',
'class'='button'));
echo $form-end();
?
/div
/div
div class=grid_6nbsp;/div


Here is the content of my default.po file that is in the directory /
app/locale/eng/LC_MESSAGES/

msgid 
msgstr 
Project-Id-Version: \n
POT-Creation-Date: \n
PO-Revision-Date: \n
Last-Translator: Steven Wright swri...@etisoftware.com\n
Language-Team: \n
MIME-Version: 1.0\n
Content-Type: text/plain; charset=iso-8859-1\n
Content-Transfer-Encoding: 8bit\n

msgid Please Login
msgstr Please Login



1) I am assuming I need to tell Cake to use I18n. But how? Is it a
component, a helper?
2) Does my .po file look correct?
3) Am I on the right path?

Thanks

--~--~-~--~~~---~--~~
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: Internationalization

2009-08-17 Thread RhythmicDevil

Ok problem solved is that my PHP was not compiled with gettext. So
thats done. The page loads but there is not message being displayed.




On Aug 17, 4:52 pm, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hi,
 I am trying to understand how to get internationalization to work in
 CakePHP. After reading the docs and searching around, looking at
 Teknoid and some other place this is what I am left with.

 CakePHP has a class I18n that handles the loading of the correct
 string from a .po file based upon the language locale setting.

 CakePHP has a console app that supposedly will read all the strings in
 your view files and create language files for you.

 I wrap my string ids in _() which will return the msg for that id.

 I can use POEdit to create my files.

 Given that. I created one message and placed it in the default.po file
 for English. I then used the translator function for the heading on my
 login page. However when I start the app it simply fails and tells me
 that _()  is an undefined function.

 Here is the content of my controller:

 class SubscribersController extends Controller
 {
     public $helpers = array ('Form', 'Html', 'Javascript');
     public $components = array ('DataPrep');

     public $SubscriberId = null;

     public function login()
     {
         $this-pageTitle = 'Please Login';
         $this-layout = 'login';
         $this-SubscriberId = $this-params['data']['Subscriber']
 ['SubscriberId'];
         $this-log('Login attempt with SubscriberId: '.$this-SubscriberId, 
 Configure::read('APP_LOG'));

         $subscriber = $this-Subscriber-QuerySub($this-SubscriberId);

         if ($subscriber-resultCode == 0)
         {
             $this-Session-write('Subscriber', $subscriber-querySubRsp);

             //debug($this-Session-read('Subscriber'));
             $this-redirect( array ('controller'='subscribers',
 'action'='basics'));
         }

     }
 

 Here is the content of my View file:

 div class=grid_6nbsp;/div
         div class=grid_4 style=margin-top:200px; background:#FFF;
                 div style=text-align:center; font-weight:bold;?php 
 _(Please
 Login); ?/div
                 div style=padding:20px;

                 ?php
                         echo $form-create($options = array('action' = 
 'login'));
                         echo $form-input('Subscriber.SubscriberId');
                         echo $form-button('Login', array('type'='submit',
 'class'='button'));
                         echo $form-end();
                 ?
                 /div
         /div
 div class=grid_6nbsp;/div

 Here is the content of my default.po file that is in the directory /
 app/locale/eng/LC_MESSAGES/

 msgid 
 msgstr 
 Project-Id-Version: \n
 POT-Creation-Date: \n
 PO-Revision-Date: \n
 Last-Translator: Steven Wright swri...@etisoftware.com\n
 Language-Team: \n
 MIME-Version: 1.0\n
 Content-Type: text/plain; charset=iso-8859-1\n
 Content-Transfer-Encoding: 8bit\n

 msgid Please Login
 msgstr Please Login

 1) I am assuming I need to tell Cake to use I18n. But how? Is it a
 component, a helper?
 2) Does my .po file look correct?
 3) Am I on the right path?

 Thanks
--~--~-~--~~~---~--~~
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: Internationalization

2009-08-17 Thread RhythmicDevil

Hahaha I am such a dummy. Thanks.



On Aug 17, 4:59 pm, Larry E. Masters aka PhpNut php...@gmail.com
wrote:
 It is __(); notice the double underscore.

 --
 /**
 * @author Larry E. Masters
 * @var string $userName
 * @param string $realName
 * @returns string aka PhpNut
 * @access  public
 */

 On Mon, Aug 17, 2009 at 3:52 PM, RhythmicDevil rhythmicde...@gmail.comwrote:



  Hi,
  I am trying to understand how to get internationalization to work in
  CakePHP. After reading the docs and searching around, looking at
  Teknoid and some other place this is what I am left with.

  CakePHP has a class I18n that handles the loading of the correct
  string from a .po file based upon the language locale setting.

  CakePHP has a console app that supposedly will read all the strings in
  your view files and create language files for you.

  I wrap my string ids in _() which will return the msg for that id.

  I can use POEdit to create my files.

  Given that. I created one message and placed it in the default.po file
  for English. I then used the translator function for the heading on my
  login page. However when I start the app it simply fails and tells me
  that _()  is an undefined function.

  Here is the content of my controller:

  class SubscribersController extends Controller
  {
     public $helpers = array ('Form', 'Html', 'Javascript');
     public $components = array ('DataPrep');

     public $SubscriberId = null;

     public function login()
     {
         $this-pageTitle = 'Please Login';
         $this-layout = 'login';
         $this-SubscriberId = $this-params['data']['Subscriber']
  ['SubscriberId'];
         $this-log('Login attempt with SubscriberId: '.$this-
  SubscriberId, Configure::read('APP_LOG'));
         $subscriber = $this-Subscriber-QuerySub($this-
  SubscriberId);
         if ($subscriber-resultCode == 0)
         {
             $this-Session-write('Subscriber', $subscriber-
  querySubRsp);
             //debug($this-Session-read('Subscriber'));
             $this-redirect( array ('controller'='subscribers',
  'action'='basics'));
         }

     }
  

  Here is the content of my View file:

  div class=grid_6nbsp;/div
         div class=grid_4 style=margin-top:200px; background:#FFF;
                 div style=text-align:center; font-weight:bold;?php
  _(Please
  Login); ?/div
                 div style=padding:20px;

                 ?php
                         echo $form-create($options = array('action' =
  'login'));
                         echo $form-input('Subscriber.SubscriberId');
                         echo $form-button('Login', array('type'='submit',
  'class'='button'));
                         echo $form-end();
                 ?
                 /div
         /div
  div class=grid_6nbsp;/div

  Here is the content of my default.po file that is in the directory /
  app/locale/eng/LC_MESSAGES/

  msgid 
  msgstr 
  Project-Id-Version: \n
  POT-Creation-Date: \n
  PO-Revision-Date: \n
  Last-Translator: Steven Wright swri...@etisoftware.com\n
  Language-Team: \n
  MIME-Version: 1.0\n
  Content-Type: text/plain; charset=iso-8859-1\n
  Content-Transfer-Encoding: 8bit\n

  msgid Please Login
  msgstr Please Login

  1) I am assuming I need to tell Cake to use I18n. But how? Is it a
  component, a helper?
  2) Does my .po file look correct?
  3) Am I on the right path?

  Thanks
--~--~-~--~~~---~--~~
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: Internationalization

2009-08-17 Thread RhythmicDevil

Thanks Larry, thats the trick.

On Aug 17, 4:59 pm, Larry E. Masters aka PhpNut php...@gmail.com
wrote:
 It is __(); notice the double underscore.

 --
 /**
 * @author Larry E. Masters
 * @var string $userName
 * @param string $realName
 * @returns string aka PhpNut
 * @access  public
 */

 On Mon, Aug 17, 2009 at 3:52 PM, RhythmicDevil rhythmicde...@gmail.comwrote:



  Hi,
  I am trying to understand how to get internationalization to work in
  CakePHP. After reading the docs and searching around, looking at
  Teknoid and some other place this is what I am left with.

  CakePHP has a class I18n that handles the loading of the correct
  string from a .po file based upon the language locale setting.

  CakePHP has a console app that supposedly will read all the strings in
  your view files and create language files for you.

  I wrap my string ids in _() which will return the msg for that id.

  I can use POEdit to create my files.

  Given that. I created one message and placed it in the default.po file
  for English. I then used the translator function for the heading on my
  login page. However when I start the app it simply fails and tells me
  that _()  is an undefined function.

  Here is the content of my controller:

  class SubscribersController extends Controller
  {
     public $helpers = array ('Form', 'Html', 'Javascript');
     public $components = array ('DataPrep');

     public $SubscriberId = null;

     public function login()
     {
         $this-pageTitle = 'Please Login';
         $this-layout = 'login';
         $this-SubscriberId = $this-params['data']['Subscriber']
  ['SubscriberId'];
         $this-log('Login attempt with SubscriberId: '.$this-
  SubscriberId, Configure::read('APP_LOG'));
         $subscriber = $this-Subscriber-QuerySub($this-
  SubscriberId);
         if ($subscriber-resultCode == 0)
         {
             $this-Session-write('Subscriber', $subscriber-
  querySubRsp);
             //debug($this-Session-read('Subscriber'));
             $this-redirect( array ('controller'='subscribers',
  'action'='basics'));
         }

     }
  

  Here is the content of my View file:

  div class=grid_6nbsp;/div
         div class=grid_4 style=margin-top:200px; background:#FFF;
                 div style=text-align:center; font-weight:bold;?php
  _(Please
  Login); ?/div
                 div style=padding:20px;

                 ?php
                         echo $form-create($options = array('action' =
  'login'));
                         echo $form-input('Subscriber.SubscriberId');
                         echo $form-button('Login', array('type'='submit',
  'class'='button'));
                         echo $form-end();
                 ?
                 /div
         /div
  div class=grid_6nbsp;/div

  Here is the content of my default.po file that is in the directory /
  app/locale/eng/LC_MESSAGES/

  msgid 
  msgstr 
  Project-Id-Version: \n
  POT-Creation-Date: \n
  PO-Revision-Date: \n
  Last-Translator: Steven Wright swri...@etisoftware.com\n
  Language-Team: \n
  MIME-Version: 1.0\n
  Content-Type: text/plain; charset=iso-8859-1\n
  Content-Transfer-Encoding: 8bit\n

  msgid Please Login
  msgstr Please Login

  1) I am assuming I need to tell Cake to use I18n. But how? Is it a
  component, a helper?
  2) Does my .po file look correct?
  3) Am I on the right path?

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



No Error Messages

2009-08-13 Thread RhythmicDevil

Hello,
I am developing an app using Cake on my XP box using Apache 2.2, MySQL
and SOAP. The app runs just fine on my XP machine. However when I move
it to a Linux demo box all hell breaks loose. Whats making it really
hard to debug is that I am getting no error output. Not on the screen,
not in the logs and not in the Apache logs either no matter what I
set: Configure::write('debug', 2); to. I know for sure that the debug
level is not being over written as well.

Currently I have to two sections to the app. One uses MySQL that works
fine. One uses SOAP and I have a data source set up for it that seems
to be giving me problems.

I know there is an error because the browser title is set to Errors
and the page only partially loads. This is all I get:

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
titleErrors/title

link rel=stylesheet type=text/css href=/css/default.css /link
rel=stylesheet type=text/css href=/css/ui.jqgrid.css /link
rel=stylesheet type=text/css href=/css/custom-theme/jquery-
ui-1.7.2.custom.css /

All the views in the app use the same layout file and as I stated
before they load just fine. The only thing that I can think of is that
because this does not use a Model its causing some issue. But seeing
as it the exact same code works on my XP I am completely at a loss for
why this would be.

Thanks for any help.

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



Js URL

2009-08-03 Thread RhythmicDevil

Hi,
I am using CakePHP for my application. I am in the process of adding
jQgrid and I am having a problem loading the language file. CakePHP
complains that there is no controller for it?! I have no idea why
though. I have verified that the files are all in the correct place. I
have moved the language file to different locations but it made no
difference. I tried loading by writing out the script tag by hand,
still no difference.

This is from my default layout:

?php
echo $html-css('default');
echo $html-css('custom-theme/jquery-ui-1.7.2.custom');
echo $javascript-link('jquery-1.3.2.min.js');
echo $javascript-link('jquery-ui-1.7.2.custom.min.js');
echo $javascript-link('jquery.jqGrid.min.js');
echo $javascript-link('i18n/grid.local-en.js');
echo $javascript-link('jquery.json-1.3.min.js');
echo $javascript-link('app.js');
?

This is what Firebug shows me:

script src=/js/i18n/grid.local-en.js type=text/javascript
1!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
2 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
3html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
4head
5titleMissing Controller/title

$___dataForView = array(
13 controller = JsController,
14 controllerName = Js,
15 title_for_layout = Missing Controller,
16 content_for_layout = lt;h2gt;Missing Controllerlt;/h2gt;

any help would be appreciated.

thanks.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Models and SOAP

2009-06-29 Thread RhythmicDevil

Hi,
some of my application's models will use SOAP or MySQL. I am trying to
figure out where to put the common SOAP stuff.

User Model will use MySQL
Subscriber Model will use SOAP
Device Model will use SOAP

In my SOAP models I need to have this:

$api_config = Configure::read('API');

$this-TransactionParams['loginName'] = $api_config
['loginName'];
$this-TransactionParams['loginPassword'] = $api_config
['loginPassword'];
$this-TransactionParams['orgName'] = $api_config['orgName'];

$this-TransactionParams['transaction']['id'] = date('d-m-y-
i:s:a').' - ';
$this-TransactionParams['transaction']['wait'] = $api_config
['wait'];
$this-TransactionParams['transaction']['version'] =
$api_config['version'];
$this-TransactionParams['transaction']
['TransactionCommandList'] = array ();

Currently this sits in the constructor for Subscriber but I know thats
wrong as I would then have to repeat that for each subsequent model
that uses SOAP. I am using this for my datasource:
http://www.pagebakers.nl/2008/12/18/soapsource-a-soap-client-datasource-for-cakephp/

I thought a behavior would be the trick but I am not sure. The docs
dont seem to point in that direction.
I dont want to extend app_model because that would then add it to the
models that use MySQL.

Any ideas?

Thanks.
--~--~-~--~~~---~--~~
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: Models and SOAP

2009-06-29 Thread RhythmicDevil

Thats what I thought too, but when I do that I get an error that the
SoapModel class cannot be found.

class SoapModel extends AppModel
{
public function __construct()
{
parent::__construct();

$api_config = Configure::read('API');

$this-TransactionParams['loginName'] = $api_config
['loginName'];
$this-TransactionParams['loginPassword'] = $api_config
['loginPassword'];
$this-TransactionParams['orgName'] = $api_config['orgName'];

$this-TransactionParams['transaction']['id'] = date('d-m-y-
i:s:a').' - ';
$this-TransactionParams['transaction']['wait'] = $api_config
['wait'];
$this-TransactionParams['transaction']['version'] =
$api_config['version'];
$this-TransactionParams['transaction']
['TransactionCommandList'] = array ();
}
}



class Subscriber extends SoapModel
{
/**
 * @var useDbConfig
 * @description The name of the DataSource connection that this
Model uses. Defined in core/database.php
 */
public $useDbConfig = 'soap';
public $useTable = false;

public $TransactionParams = array ();

public function __construct()
{
parent::__construct();
}

}


Both these files are in the app/models directory.


Steve




On Jun 29, 12:58 pm, Carlos Gonzalez Lavin carloslavi...@gmail.com
wrote:
 How about a little class hierarchy?

 Soap extends AppModel and Suscriber-Device extend Soap

 You put that in Soap's constructor and then just super() it in
 Suscriber-Device

 2009/6/29 RhythmicDevil rhythmicde...@gmail.com



  Hi,
  some of my application's models will use SOAP or MySQL. I am trying to
  figure out where to put the common SOAP stuff.

  User Model will use MySQL
  Subscriber Model will use SOAP
  Device Model will use SOAP

  In my SOAP models I need to have this:

         $api_config = Configure::read('API');

         $this-TransactionParams['loginName'] = $api_config
  ['loginName'];
         $this-TransactionParams['loginPassword'] = $api_config
  ['loginPassword'];
         $this-TransactionParams['orgName'] = $api_config['orgName'];

         $this-TransactionParams['transaction']['id'] = date('d-m-y-
  i:s:a').' - ';
         $this-TransactionParams['transaction']['wait'] = $api_config
  ['wait'];
         $this-TransactionParams['transaction']['version'] =
  $api_config['version'];
         $this-TransactionParams['transaction']
  ['TransactionCommandList'] = array ();

  Currently this sits in the constructor for Subscriber but I know thats
  wrong as I would then have to repeat that for each subsequent model
  that uses SOAP. I am using this for my datasource:

 http://www.pagebakers.nl/2008/12/18/soapsource-a-soap-client-datasour...

  I thought a behavior would be the trick but I am not sure. The docs
  dont seem to point in that direction.
  I dont want to extend app_model because that would then add it to the
  models that use MySQL.

  Any ideas?

  Thanks.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Login validation error messages

2009-06-25 Thread RhythmicDevil

Hello,
I am trying to figure out why my login form fields are not showing
errors. From what I have read if I used cake's built in form stuff and
setup a validation array this should happen automatically if I call
validate on the model. If I dump the Model I can see that there are
errors in the validationErrors array. Do I actually have to set those
errors for the View from the Controller?

I have tried using $form-error() but I get nothing.
If I invalidate the field in the controller the field gets marked with
an error.


My ultimate goal is that I want each field to change to an error style
and place a message next to it describing the error.

Thanks for any help


MODEL

class User extends AppModel
{

var $validate = array (
'username'= array (
'rule'='notEmpty',
'required' = true,
'message'='Username is required'
),
'password'= array (
'rule'='notEmpty',
'required' = true,
'message'='Password is required'
)
);


function validateLogin($data)
{
$user = $this-find( array ('username'=$data['username'],
'password'=md5($data['password'])), array ('id', 'username'));

if ( empty($user) == false)
{
return $user['User'];
}

return false;
}
}





CONTROLLER

class UsersController extends AppController
{
public $layout = 'login';
public $fields = array ('username', 'password');

function index()
{
print Index;
}

function login()
{
// If data has been submitted
if ( empty($this-data) == false)
{
// Pass the data to the model
$this-User-set($this-data);

// If the data validates
if ($this-User-validates())
{
// If the login succeeds
if (($user = $this-User-validateLogin($this-data
['User'])) == true)
{
$this-Session-write('User', $user);
$this-Session-setFlash('You\'ve successfully
logged in.');
$this-redirect('/subscribers/index');
exit ();
}
else // If the login fails
{
$this-Session-setFlash('Login failed, please try
again.');
$this-redirect('index');
exit ();
}
}
else // If the data does not validate
{
debug($this-User);
$this-redirect('index');
exit ();
}
}

}

function logout()
{
$this-Session-destroy('user');
$this-Session-setFlash('You\'ve successfully logged out.');
$this-redirect('login');
}
}



VIEW

!-- START LOGIN FORM --
div class=grid_4 prefix_4 suffix_4
?php echo $form-create('User', array('action' = 'login'));?
div class=box style=margin-top:25%;
h5Please Login/h5
div class=body
table style=width:70%; margin:0 auto 
0 auto;
?php

$session-flash();
?
tr
td colspan=2 
class=form_element
?php
echo 
$form-input('User.username');
?
/td
/tr
tr
td colspan=2 
class=form_element
?php echo 
$form-input('User.password');?
/td
/tr
tr
td colspan=2
?php echo 
$form-submit('Login');?
/td
/tr
/table
/div
div class=footernbsp;/div
/div
?php echo $form-end(); ?
/div
!-- END LOGIN FORM --
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 

Re: Login validation error messages

2009-06-25 Thread RhythmicDevil
Had to remove the redirect for when the validation failed




On Jun 25, 2:38 pm, RhythmicDevil rhythmicde...@gmail.com wrote:
 Hello,
 I am trying to figure out why myloginform fields are not showing
 errors. From what I have read if I used cake's built in form stuff and
 setup avalidationarray this should happen automatically if I call
 validate on the model. If I dump the Model I can see that there are
 errors in the validationErrors array. Do I actually have to set those
 errors for the View from the Controller?

 I have tried using $form-error() but I get nothing.
 If I invalidate the field in the controller the field gets marked with
 anerror.

 My ultimate goal is that I want each field to change to anerrorstyle
 and place a message next to it describing theerror.

 Thanks for any help

 MODEL

 class User extends AppModel
 {

     var $validate = array (
         'username'= array (
                 'rule'='notEmpty',
                 'required' = true,
                         'message'='Username is required'
         ),
         'password'= array (
                 'rule'='notEmpty',
                 'required' = true,
                 'message'='Password is required'
         )
     );

     function validateLogin($data)
     {
         $user = $this-find( array ('username'=$data['username'],
 'password'=md5($data['password'])), array ('id', 'username'));

         if ( empty($user) == false)
         {
             return $user['User'];
         }

         return false;
     }

 }

 CONTROLLER

 class UsersController extends AppController
 {
     public $layout = 'login';
     public $fields = array ('username', 'password');

     function index()
     {
         print Index;
     }

     functionlogin()
     {
         // If data has been submitted
         if ( empty($this-data) == false)
         {
             // Pass the data to the model
             $this-User-set($this-data);

             // If the data validates
             if ($this-User-validates())
             {
                 // If theloginsucceeds
                 if (($user = $this-User-validateLogin($this-data
 ['User'])) == true)
                 {
                     $this-Session-write('User', $user);
                     $this-Session-setFlash('You\'ve successfully
 logged in.');
                     $this-redirect('/subscribers/index');
                     exit ();
                 }
                 else // If theloginfails
                 {
                     $this-Session-setFlash('Loginfailed, please try
 again.');
                     $this-redirect('index');
                     exit ();
                 }
             }
             else // If the data does not validate
             {
                 debug($this-User);
                     $this-redirect('index');
                     exit ();
             }
         }

     }

     function logout()
     {
         $this-Session-destroy('user');
         $this-Session-setFlash('You\'ve successfully logged out.');
         $this-redirect('login');
     }

 }

 VIEW

 !-- STARTLOGINFORM --
         div class=grid_4 prefix_4 suffix_4
                 ?php echo $form-create('User', array('action' = 
 'login'));?
                         div class=box style=margin-top:25%;
                                 h5PleaseLogin/h5
                                 div class=body
                                         table style=width:70%; margin:0 
 auto 0 auto;
                                                 ?php

                                                         $session-flash();
                                                 ?
                                                 tr
                                                         td colspan=2 
 class=form_element
                                                                 ?php
                                                                         echo 
 $form-input('User.username');
                                                                 ?
                                                         /td
                                                 /tr
                                                 tr
                                                         td colspan=2 
 class=form_element
                                                                 ?php echo 
 $form-input('User.password');?
                                                         /td
                                                 /tr
                                                 tr
                                                         td colspan=2
                                                                 ?php echo 
 $form-submit('Login');?
                                                         /td
                                                 /tr
                                         /table
                                 /div
                                 div class=footernbsp;/div

Validation

2009-06-15 Thread RhythmicDevil

Hi,
having a little problem with validation. I am not using a DB. I have
to auth against Web Services. I am currently just working on the login
page trying to get messages to the view when validation fails.

Here is the Model:

class User extends AppModel
{
var $useDbConfig = 'soap';
var $useTable = false;

var $validate = array(
'username' = array(

'required' = true

,'allowEmpty' = false

,'message' = 'Username is required'

)
,'password' = array(

'required' = true

,'allowEmpty' = false

,'message' = 'Password is required'

)
);
}

Here is the Controller:


class UsersController extends AppController
{
public $layout = 'login';
public $fields = array ('username', 'password');


function index()
{

}

function login()
{

// First set the data to the model
$this-User-set( $this-data );

// Check for validity
if($this-User-validates())
{
print 'valid';
}
else
{
print 'invalid';
}
$this-render('index');
}

function logout()
{

}
}


So pretty straight forward stuff. However when I submit the form I get
the following error from Cake whether there is data in the fields or
not:

Warning (2): preg_match() [function.preg-match]: Delimiter must not be
alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2431]

Code | Context

$this   =   User
User::$useDbConfig = soap
User::$useTable = false
User::$validate = array
User::$displayField = NULL
User::$id = false
User::$data = array
User::$table = users
User::$primaryKey = id
User::$_schema = NULL
User::$validationErrors = array
User::$tablePrefix = NULL
User::$name = User
User::$alias = User
User::$tableToModel = array
User::$logTransactions = false
User::$transactional = false
User::$cacheQueries = false
User::$belongsTo = array
User::$hasOne = array
User::$hasMany = array
User::$hasAndBelongsToMany = array
User::$actsAs = NULL
User::$Behaviors = BehaviorCollection object
User::$whitelist = array
User::$cacheSources = true
User::$findQueryType = NULL
User::$recursive = 1
User::$order = NULL
User::$__exists = NULL
User::$__associationKeys = array
User::$__associations = array
User::$__backAssociation = array
User::$__insertID = NULL
User::$__numRows = NULL
User::$__affectedRows = NULL
User::$_findMethods = array
User::$_log = NULL
$options=   array()
$data   =   array(
username = ,
password = 
)
$methods=   array(
__construct,
call__,
bind,
bindmodel,
unbindmodel,
__createlinks,
__constructlinkedmodel,
__generateassociation,
setsource,
set,
deconstruct,
schema,
getcolumntypes,
getcolumntype,
hasfield,
create,
read,
field,
savefield,
save,
__savemulti,
updatecountercache,
_prepareupdatefields,
saveall,
__save,
updateall,
remove,
del,
delete,
_deletedependent,
_deletelinks,
deleteall,
__collectforeignkeys,
exists,
hasany,
find,
_findfirst,
_findcount,
_findlist,
_findneighbors,
_findthreaded,
__filterresults,
resetassociations,
isunique,
query,
validates,
invalidfields,
invalidate,
isforeignkey,
getdisplayfield,
escapefield,
getid,
getlastinsertid,
getinsertid,
setinsertid,
getnumrows,
getaffectedrows,
setdatasource,
getdatasource,
getassociated,
joinmodel,
beforefind,
afterfind,
beforesave,
aftersave,
beforedelete,
afterdelete,
beforevalidate,
onerror,
_clearcache,
__sleep,
__wakeup,
findall,
findcount,
findallthreaded,
findneighbours,
overload,
__call,
object,
 

where did u go?

2009-06-10 Thread RhythmicDevil

nope not the Bosstones' song but my AJAX response.

I have a button on the page. Clicking the button invokes the following
jQuery function:

   $('#refresh_sub').click(function()
{
console.log('Start');
// Add the content to the dialog
$.post(/subscribers/refresh_sub, '', function(data){
console.log('Finish');
populate_dialog(data);

$(#confirm_dialog).dialog('option', 'buttons', {
'OK': function()
{
$(#confirm_dialog).dialog('close')
}
});

$('#confirm_dialog').dialog('open');
}, 'json');

});

Which in turn invokes the following PHP method in my Subscribers
Controller:

public function refresh_sub($id = null)
{
/*
 *  PerformSubOp
 *  SubscriberId subscriber_id /SubscriberId
 *  Operation operation /Operation
 *  /PerformSubOp
 */

$this-layout = 'ajax';

$operation = $this-data['operation'];

$id = $this-data['Subscriber']['SubscriberId'];
$this-TransactionParams['transaction']['id'] . $operation;
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['PerformSubOp']
['SubscriberId'] = $id;
$this-TransactionParams['transaction']
['TransactionCommandList']['TransactionCommand']['PerformSubOp']
['Operation'] = $operation;

$result = $this-Subscriber-query('SendTransaction', $this-
TransactionParams);

$this-set('response', json_encode( array ('title'='Success',
'message'='Message content', 'level'='Success')));
}


The view then does this:

?php echo $response; ?


Pretty standard stuff. However my jQuery function never gets the data
back. If you look you will see I have two console.log() calls the
jQuery function. The first one fires but the second does not.
I know that the json data is being returned because I can see it in
the HTTP response in Firebug.

This basic transaction works in my custom framework. But I am moving
over to Cake and I am wondering where I went wrong.

Thanks for any help.
--~--~-~--~~~---~--~~
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: where did u go?

2009-06-10 Thread RhythmicDevil

Solved this. The problem was that I had Configure::write('debug', 3);
so there was all sort of extra junk in the response. When I set it to
0 it works fine. Now I just to figure out how to get debug when I need
it without juggling the config file.




On Jun 10, 1:44 pm, RhythmicDevil rhythmicde...@gmail.com wrote:
 nope not the Bosstones' song but my AJAX response.

 I have a button on the page. Clicking the button invokes the following
 jQuery function:

    $('#refresh_sub').click(function()
     {
                 console.log('Start');
                 // Add the content to the dialog
         $.post(/subscribers/refresh_sub, '', function(data){
                 console.log('Finish');
                         populate_dialog(data);

                         $(#confirm_dialog).dialog('option', 'buttons', {
                                 'OK': function()
                                 {
                                         $(#confirm_dialog).dialog('close')
                                 }
                         });

                         $('#confirm_dialog').dialog('open');
                 }, 'json');

     });

 Which in turn invokes the following PHP method in my Subscribers
 Controller:

         public function refresh_sub($id = null)
         {
         /*
          *      PerformSubOp
          *              SubscriberId subscriber_id /SubscriberId
          *              Operation operation /Operation
          *      /PerformSubOp
          */

                 $this-layout = 'ajax';

                 $operation = $this-data['operation'];

                 $id = $this-data['Subscriber']['SubscriberId'];
                 $this-TransactionParams['transaction']['id'] . $operation;
         $this-TransactionParams['transaction']
 ['TransactionCommandList']['TransactionCommand']['PerformSubOp']
 ['SubscriberId'] = $id;
         $this-TransactionParams['transaction']
 ['TransactionCommandList']['TransactionCommand']['PerformSubOp']
 ['Operation'] = $operation;

         $result = $this-Subscriber-query('SendTransaction', $this-

 TransactionParams);

                 $this-set('response', json_encode( array ('title'='Success',
 'message'='Message content', 'level'='Success')));
         }

 The view then does this:

 ?php echo $response; ?

 Pretty standard stuff. However my jQuery function never gets the data
 back. If you look you will see I have two console.log() calls the
 jQuery function. The first one fires but the second does not.
 I know that the json data is being returned because I can see it in
 the HTTP response in Firebug.

 This basic transaction works in my custom framework. But I am moving
 over to Cake and I am wondering where I went wrong.

 Thanks for any help.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Sub templating

2009-06-09 Thread RhythmicDevil

Hello,
I have a view.ctp for a Subscriber. I want to break up the view into
several smaller templates as there are tabs and all sort of stuff on
the view. However logically the small pieces dont belong in elements
as they are not used anywhere else. I want to put them in views/
subscribers and just include them into the view.ctp template.


app/
views/
subscribers/
view.ctp
subview1.ctp
subview2.ctp


1) Is that possible?
2) Is that correct within Cake's framework?

Thanks
Steve

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



Brain sprain

2009-03-03 Thread RhythmicDevil

Hi,
I am having a brain sprain. I have a controller Subscribers that has
two actions 'view' and 'add_device'. View is called from the index
page with a Subscriber ID and then shows all the Subscriber's details.
In the 'view' view there is a form to add a device. This form's action
points at 'subscribers/add_device' and passes the subscriber_id and
the device_id.

If the device_id is empty I want to send the user back to the 'view'
view (I have to change that name) populated with the Subscriber's
data. For some reason I cant figure out how to do that in a simple
way. Because each call to a view is separate request the data does not
persist. Would someone be so kind as to point out the obvious to me?

In reality I should probably do a validation on the client, but this
case would still have to be handled after a device is added. I would
want the user sent back to the 'view' view to see the updated data.

Thanks.
Steve


?php
class SubscribersController extends AppController
{

var $helpers = array('Html', 'Javascript');

function index()
{
$this-pageTitle = 'Subscriber';
$this-layout = 'default';
}

function view()
{
debug($this-data);
if(! empty($this-data['Subscriber']['subscriber_id']))
{
if(! $data = 
$this-Subscriber-fetchSubscriber($this-data
['Subscriber']['subscriber_id']))
{
$this-redirect('/subscribers/index'); // TODO 
no result handle
this!
}
$this-set('subscriber', $data);
$this-pageTitle = 'Subscriber';
$this-layout = 'default';
}
else
{
$this-redirect('/subscribers/index');
}


}

function add_device()
{
$this-autoRender = false;
//debug($this-data);
if(! empty($this-data['Subscriber']['device_id']))
{
// handle adding the device
debug($this-data);

// Then reroute back to the view
}
else
{
$this-redirect(array('controller' = 'subscribers', 
'action' =
'view'));
}

}
}
?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Not using a DB for data

2009-02-25 Thread RhythmicDevil

Hi,
I have a set of views in my app that will not be using a database. The
data will be coming from an web method. I believe I still need to use
a model to stay within MVC. So I have my model set up like this with a
test method:

class Workorder extends AppModel
{
var $useTable = false;

public function fetchAllWorkdOrders()
{
$data = array();

$data[] = array('id' = '01', 'workorder' = 'Move outlet');
$data[] = array('id' = '02', 'workorder' = 'Add outlet');
$data[] = array('id' = '03', 'workorder' = 'Turn on HBO');
$data[] = array('id' = '04', 'workorder' = 'Allow PPV');
$data[] = array('id' = '05', 'workorder' = 'Add device');

return $data;
}
}

However when I try to access the index view that calls the
fetchAllWorkOrders method I get a SQL error even though I specified
not to use a table. Are there other steps to let the model know that
it does not use a db? Or am I on the wrong path?

Thanks

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