Re: HABTM Count

2009-04-09 Thread yodi

You can use Set::extract for tidying array

On Thu, 2009-04-09 at 06:56 -0700, rossjha wrote:
> This seems to be working.
> 
> $this->Tag->unbindModel(array('hasAndBelongsToMany' => array
> ('Improvements')));
> $this->Tag->bindModel(array('hasOne' => array(
>   'ImprovementsTag',
>   'FilterTag' => array(
>   'className' => 'Tag',
>   'foreignKey' => false,
>   'conditions' => array('FilterTag.id =
> ImprovementsTag.tag_id')
>   )
> )));
>   $tags = $this->Tag->find('all', array(
>   'conditions'=>null,
>   'fields' => array('Tag.*', 'COUNT(FilterTag.id) 
> AS no_tags'),
>   'group' => 'Tag.id'
>   ));
> 
> Array
> (
> [0] => Array
> (
> [Tag] => Array
> (
> [id] => 1
> [title] => Effective Glucose Control
> )
> 
> [0] => Array
> (
> [no_tags] => 2
> )
> 
> )
> 
> Is there a way of tidying this array so no_tags is part of the Tag
> element?
> 
> Cheers
> 
> R
> 
> On Apr 9, 1:45 pm, "ross.hagg...@googlemail.com"
>  wrote:
> > Hi i have the following associations:
> >
> > var $hasAndBelongsToMany = array('Improvements');
> > var $hasAndBelongsToMany = array('Tags');
> >
> > With a join table improvements_tags
> >
> > I want to be able to count the number of time a tag has been used.
> > The following sql query works, but i'm not sure how to do this in
> > CakePHP?
> >
> > SELECT tags.id, tags.title, COUNT(improvements_tags.tag_id) AS no_tags
> > FROM tags, improvements_tags WHERE tags.id = improvements_tags.tag_id
> > GROUP BY tags.id
> >
> > I've tried to bindModel with a count in the find condition, but it
> > never seems to work.  Any help would be really appreciated.
> >
> > Ross
> > 


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



Setting up ACL permissions

2009-04-09 Thread djXternal

Hey everyone I have been following the tutorial on setting up an ACL
system, and everything has gone well until I got the the section on
setting permissions: http://book.cakephp.org/view/648/Setting-up-permissions

I put in the initDb() code they give you there, but when I try and
load the page to executre the function I get a "Undefined variable:
group" and "Object of class Group could not be converted to int" all
on the "$group &= $this->User->Group;" statement.  I have check my
relationships and they are all good, what else could cause this issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: AppController not loaded for missing controller pages

2009-04-09 Thread Dr. Loboto

Make you own error handler and call these methods manually if it
wasn't done in normal flow. It is the only way.

On Apr 8, 11:21 pm, "rich...@home"  wrote:
> In my AppController, I set a bunch of view variables in the
> beforeFilter() {} callback.
>
> I use these view variables ($authUser) in the layout to for e.g. a
> welcome  block.
>
> If the user goes to a page that doesn't exist, then AppController
> isn't loaded at all and these view variables aren't populated which
> produces error messages all over the place :-(
>
> I realise that these errors wont show with debug 0, but neither will
> the values of the vars I've set.
>
> Where can I set these vars so that that are always available to the
> layout under all conditions?
>
> Thanks in advance :-)
--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread mscdex

On Apr 9, 3:08 pm, "smithtrev...@googlemail.com"
 wrote:
> Ok, now I've done that, I've spent the last couple of hours trying to
> insert the parsed xml into a database table called teams.
>

Well, depending on what your table columns are named, you may need to
change some of the keys in the array (such as "value" to something
like "name" and "id" to something else if you don't want to use that
number as the primary key for your record(s)). Then you can do a $this-
>Model->saveAll($xml['Teams']); and it should save all the records to
the database.

Here's a simple recursive function to rename array keys:
function array_change_key($orig, $new, &$array) {
   foreach ($array as $k => $v)
   $return[$k === $orig ? $new : $k] = (is_array($v) ? $this-
>array_change_key($orig, $new, $v) : $v);
   return $return;
}

Example usage:
   $xml = file_get_contents("http://11v11.com/api/teams/season/2009/
xml/y");
   App::import('Xml');
   $xml =& new XML($xml);
   $xml = Set::reverse($xml);
   $xml = $this->array_change_key('value', 'name', $xml);
   $xml = $this->array_change_key('id', 'special_team_id', $xml);
   $success = $this->Team->saveAll($xml['Teams']);
--~--~-~--~~~---~--~~
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: Live Validation

2009-04-09 Thread yodi

If you using Jquery, maybe i can give some hand.
My method is: 

1. Sending input using JSON -> Controller.
2. Validates on controller
3. Send back report using JSON to View


On Wed, 2009-04-08 at 20:06 -0230, Dave Maharaj :: WidePixels.com wrote:
> Has anyone have any advice on live validation using the prototype
> framework? A good starting place. Searched but found nothing. Also is
> it possible to apply live validating to inPlace editors?
>  
> Thanks
>  
> Dave 
> 
> > 


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

2009-04-09 Thread Manisha

Ok, thank you Miles, I will try for the thickbox.

On Apr 9, 5:09 pm, Miles J  wrote:
> Im pretty positive lightbox is images only. You would have to try
> thickbox, or another equivalent.
--~--~-~--~~~---~--~~
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: What does this mean?

2009-04-09 Thread Miles J

Have you edit the cake for libs at all? Because thats where its
located.
Or have you overwritten that method?
--~--~-~--~~~---~--~~
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: login voodoo

2009-04-09 Thread Jorge Horacio Cué Cantú
Your wellcome, sorry for the small mistake.


2009/4/9 brian 

>
> 2009/4/9 Jorge Horacio Cué Cantú :
> > Hello,
> >
> >
> > Set
> >
> > $this->Auth->redirect = false
> >
> > in AppController::beforeFilter().
> >
> > The   the login() action will be called after a successful login.
> >
>
> Thanks, that's it (sort of). The var is actually $this->Auth->autoRedirect.
>
> So, for the record:
>
> AppController:
> function beforeFilter()
> {
>$this->Auth->fields = array('username' => 'email', 'password' =>
> 'password');
>$this->Auth->loginError = 'No matching user found.';
>$this->Auth->loginAction = array('controller' => 'users', 'action'
> => 'login');
>$this->Auth->loginRedirect = array('controller' => 'pages', 'action'
> => 'display', 'home');
> $this->Auth->autoRedirect = false;
> $this->Auth->logoutRedirect = array('controller' => 'users',
> 'action'
> => 'login');
>
> if (isset($this->params['admin']) && $this->params['admin'])
>{
>$this->layout = 'admin';
>}
> }
>
>
> UsersController:
> public function login()
> {
>if ($user = $this->Auth->user())
>{
>$this->User->id = $user['User']['id'];
>$this->User->saveField('last_login', date('Y-m-d H:i:s'));
>
>if (!$user['User']['eula_accepted'])
>{
>$this->redirect(
> array('controller' => 'users', 'action' =>
> 'eula')
>);
>}
> $this->redirect($this->Auth->loginRedirect);
>}
> }
>
> public function eula()
> {
>if (!empty($this->data) && $this->data['User']['eula_accepted'])
>{
>$this->User->id = $this->Auth->user('id');
>$this->User->saveField('eula_accepted', 1);
>$this->Session->write('Auth.User.eula_accepted', 1);
>
>$this->redirect(
> array('controller' => 'pages', 'action' =>
> 'display', 'home')
> );
>}
> }
>
> Thanks again, Jorge!
>
> >
>

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



Model config for table with no ID

2009-04-09 Thread mattalexx

Hi

I am trying to access a database table that was built without a
primary key (I know). How would I go about this in CakePHP. Is it
possible or do I have to just use Model::query all the time?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



What does this mean?

2009-04-09 Thread Dave Maharaj :: WidePixels.com
I keep getting Fatal error: Call to undefined function loadmodel()
 
I have no idea what has happened butikeep seeing this error. If i delete
cookies it disappears but i am sure thats not a good thing.
 
Anynoe know why I am getting this message so i canback track to see what i
have done wrong?
 
Thanks,
 
Dave 

--~--~-~--~~~---~--~~
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: New CakePHP book available.

2009-04-09 Thread GrumpyCanuck

On Apr 3, 8:05 am, Fábio "Kym" Nascimento 
wrote:
> Hey,
>
> I'd like to see a summary of yourbookbefore buying, I think people
> wants to know a little deep what are you talking about on thebook,
> chapters and sub-chapters names at least.
>
> Thanks

Hrm...maybe I should put that up there on the site for the book.

Let me work on that.  Thanks for the suggestion.

Chris

--~--~-~--~~~---~--~~
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: Get "last deleted id" from afterDelete?

2009-04-09 Thread park

Wow, never heard of this before!

Thank you very much!

On Apr 9, 11:27 pm, grigri  wrote:
> In the afterDelete() callback, $this->id(or $model->id) in a behavior
> will refer to the just-deletedmodel. It's cleared after the callbacks
> have been called, just before Model::del() returns.
>
> hth
> grigri
>
> On Apr 9, 4:09 pm, park  wrote:
>
>
>
> > Hi,
>
> > Working on a set of models, in which after one model got its record
> > updated, the Log model will be manipulated accordingly.
>
> > $cascade = true of Model:del() doesn't seem to work, 'coz models
> > mentioned above are not associated. (Log model has a field 'item_id'
> > that is shared by all other models, recording their ids but
> > diffrentiated by another field 'model'. )
>
> > Is it possible to get thelastdeletedrecordidfrom whatever
> > beforeDelete or afterDelete callbacks?
>
> > If not, I guess I'll have to extend Model::del in order to get this,
> > right? Is there a DRY approach of doing this? (Like writing a
> > behavior)
>
> > Many 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: complex HABTM question

2009-04-09 Thread Miles J

Use Containable over Recursion.
http://book.cakephp.org/view/474/Containable
--~--~-~--~~~---~--~~
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: complex HABTM question

2009-04-09 Thread luke83
The problem is the attribute recursive: i cannot set it to 3 as i
need! Is there a way to bypass the problem or a trick to have more
deep association fatching?  Thanks!

On 9 Apr, 16:27, luke83  wrote:
> Hi there,
> first question, complex question :D
>
> i have tables in db like this:
>
> + leagues
> | - lid
> | - name
>
> + users
> | - uid
> | - name
>
> + groups
> | - gid
> | - name
>
> + league_staff
> | - lid
> | - gid
> | - uid
>
> The models:
>
> class League extends AppModel {
>     var $name = 'League';
>     var $primaryKey = 'lid';
>     var $hasAndBelongsToMany = array(
>         'Staff' =>
>             array(
>                 'className'              => 'User',
>                 'joinTable'              => 'league_staff',
>                 'foreignKey'             => 'lid',
>                 'associationForeignKey'  => 'lid',
>                 'with'                   => 'LeagueStaff',
>                 'unique'                 => true,
>                 'conditions'             => '',
>                 'fields'                 => '',
>                 'order'                  => '',
>                 'limit'                  => '',
>                 'offset'                 => '',
>                 'finderQuery'            => '',
>                 'deleteQuery'            => '',
>                 'insertQuery'            => ''
>             )
>     );
>
> }
>
> class User extends AppModel {
>     var $name = 'User';
>     var $primaryKey = 'uid';
>
> }
>
> class Group extends AppModel {
>     var $name = 'Group';
>     var $primaryKey = 'gid';
>
> }
>
> class LeagueStaff extends AppModel {
>     var $name = 'LeagueStaff';
>     var $primaryKey = 'gid';
>     var $useTable = 'league_staff';
>     var $hasOne = array(
>         'Group' => array(
>             'className'              => 'Group',
>             'foreignKey'             => 'gid',
>         )
>     );
>
> }
>
> This is what i got:
>
> [leagues] => Array
>                 (
>                     [0] => Array
>                         (
>                             [League] => Array
>                                 (
>                                     [lid] => 1
>                                     [name] => first league
>                                 )
>
>                             [Staff] => Array
>                                 (
>                                     [0] => Array
>                                         (
>                                             [uid] => 1
>                                             [name] => luke83
>                                             [LeagueStaff] => Array
>                                                 (
>                                                     [lid] => 1
>                                                     [uid] => 1
>                                                     [gid] => 1
>                                                 )
>
>                                         )
>
>                                 )
>
>                         )
>                 )
>
> This is what i would like:
>
> [leagues] => Array
>                 (
>                     [0] => Array
>                         (
>                             [League] => Array
>                                 (
>                                     [lid] => 1
>                                     [name] => first league
>                                 )
>
>                             [Staff] => Array
>                                 (
>                                     [0] => Array
>                                         (
>                                             [uid] => 1
>                                             [name] => luke83
>                                             [Group] => Array
>                                                 (
>                                                     [gid] => 1
>                                                     [name] => admin
>                                                 )
>
>                                         )
>
>                                 )
>
>                         )
>                 )
>
> it is like when LeagueStaff is invoked the hasOne attribute is not
> considered
>
> Can someone explain me what i do wrong?
>
> Thanks for time :D
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination with non-fixed page size (how can I customize paginateCount?)

2009-04-09 Thread ahmedhelmy007

Hi all.

A brief description of my problem:

I need to make pagination with non-fixed page size, every page must
contain items from certain month only. I wrote the query correctly ,
but the CAKE cannot count pages correctly because it calculates the
number of pages by dividing the total count of items by the page size -
the $limit variable- .

how can i make a custom paginateCount that returns the right number of
pages instead of the total count of items ?
I want a way to provide the CAKE with the number of pages instead of
leaving paginateCount to calculate it by dividing the total count of
items by the page size.

Is there any way to do this without hacking the core ? Or I will have
to dispense with the CAKE pagination and make my own one?


Detailed problem description:

I have a table called “sermons”  , each sermon have a “hijri_date”
field holds the sermon date.

The table is something like this:

 id |   hijri_date   |
-|--|
 1  |  1429-1-1|
 2  |  1429-1-8|
 3  |  1429-1-15  |
 4  |  1429-1-22  |
 5  |  1429-3-5|
 6  |  1429-3-12  |
 7  |  1429-4-4|



I wanted to display sermons with pagination, each page contains the
sermon of a certain month.

According to the above table pages will be like this:

page 1 - all sermons that was in month #1 - :

id  |   hijri_date   |
-|---|
 1  |  1429-1-1|
 2  |  1429-1-8|
 3  |  1429-1-15  |
 4  |  1429-1-22  |


page 2 - all sermons that was in month #3 - :

id  |   hijri_date   |
|---|
 5  |  1429-3-5|
 6  |  1429-3-12  |


page 3  - all sermons that was in month #4 - :

id  |   hijri_date   |
-|--|
 7  |  1429-4-4|




The SQL query is like this:


SELECT *
FROM sermons
WHERE CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)) = (
SELECT DISTINCT( 
CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)))
FROM sermons
ORDER BY id DESC
LIMIT $offset , 1   )
ORDER BY id DESC


here are my controller and model

sermons_controller.php:


 array());

function index() {

if(! isset($this->passedArgs["page"])) $pageNumber=0;
else $pageNumber=$this->passedArgs["page"]-1;

$this->paginate = Set::merge($this->paginate,
array('Sermon'=>array('limit'=>2, 'page'=>1, 'extra'=>
$pageNumber)));

$this->set('sermons', $this->paginate('Sermon'));
}

}
?>


and  sermon.php :

query(
"SELECT *
FROM sermons
WHERE
  CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)) = (
SELECT DISTINCT( 
CONCAT(YEAR(hijri_date),'-',MONTH(hijri_date)))
FROM sermons
ORDER BY id DESC
LIMIT $offset,1 )
ORDER BY id DESC");

}



function paginateCount($conditions = null, $recursive = 0, $extra =
array()) {

$results =$this->query(
"SELECT COUNT(DISTINCT( CONCAT(YEAR(hijri_date),'-',MONTH
(hijri_date AS monthes_count
FROM sermons”);

return $results[0][0]["monthes_count"];
}

?>
--~--~-~--~~~---~--~~
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: Lightbox

2009-04-09 Thread Miles J

Im pretty positive lightbox is images only. You would have to try
thickbox, or another equivalent.
--~--~-~--~~~---~--~~
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: Reverse "LIKE" sql statement

2009-04-09 Thread Miles J

NOT LIKE '%term%'

Is that what you mean?

http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
--~--~-~--~~~---~--~~
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: Putting a label on same line as an input field

2009-04-09 Thread Danny Lieberman

Dardo

Thanks - I already tried this direction and it doesn't affect the
location of the label - it still appears above the input box.

I can change label placement for all the forms but in this case I only
want to change one particular field label

In the view:

echo $form->input('idcode', array('label'=>'Patient ID
Code','type'=>'text','length'=>2,'maxlength'=>2, 'div' =>array('id' =>
'left-label')) );

and this is what I have in the css
left-label { float: left; width: 100px; display: block; }

label {
display: block;
font-size: 110%;
padding-right: 20px;
}
input, textarea {
clear: both;
font-size: 140%;
font-family: "frutiger linotype", "lucida grande", "verdana", sans-
serif;
padding: 2px;

Danny

On Apr 8, 5:59 pm, Dardo Sordi Bogado  wrote:
> > Wouldn't you want all labels in side a form to appear on the left?
>
> Perhaps I misunderstand the question, I thought he was asking how to
> set an specific label in the left side.
>
> > If so then why not do something along the lines of
> > label {
> >        float: left;
> >        width: 75px;
> >        display: block;
> >        clear: left;
> >        text-align: left;
> >        cursor: hand;
> >    }
>
> In that case is better not to clear the labels, so ther don't affect
> floating divs. I prefer to simply float them, and set overflow:auto to
> de wrapping divs:
>
> label { float: left; width: 75px; display: block; }
> .input { overflow: auto; }
>
> Regards,
> - Dardo.
>
> > On Apr 8, 6:31 am, Dardo Sordi Bogado  wrote:
> >> Assign some specific css selector (setting an id or class in the
> >> wrapping div should work), then set label { display: inline } or float
> >> the things left...
>
> >> $form->input('lefty-input', array('div' =>array('id' => 'make-me-left')));
>
> >> HTH,
> >> - Dardo
>
> >> On Wed, Apr 8, 2009 at 8:26 AM, Danny Lieberman  wrote:
>
> >> > This is sort of a classic css question but I have not been able to
> >> > position an label on the left side of an input field - it always
> >> > slides to the top.  When I did get the label on the left-it impacted
> >> > the layout of the entire form.
>
> >> > br
> >> > Danny
--~--~-~--~~~---~--~~
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: The right way to pass vars from a view to the layout?

2009-04-09 Thread martinp

If I've understood correctly I had a very similar problem. I was using
the inbuilt pages controller and had an 'AddThis' widget in the footer
of the layout that I generally wanted to be visible, but on certain
pages it wasn't required. All I did was at the top of the pages I
didn't want the 'AddThis' button to be visible I added '$this->noshare
= true' and then in the layout didn't show the button if $this-
>noshare was set and true.

Worked for me.

On Apr 8, 2:40 pm, John Andersen  wrote:
> Thanks for trying :)
>
> Do I understand correctly, that you are invoking/calling/whatever an
> element (Google Analytics) from the layout?
>    John
>
> On Apr 8, 2:27 pm, the_woodsman  wrote:
>
> > John, let me give it another go!
>
> > Googl analytics is still my best example.
>
> > I want every single page to have the basic analytics snippet.
> > I really don't want to have this in every single view- it'd be a big
> > job to go through all the existing views and add the call to render
> > the element (not very DRY), it makes my views more cluttered, and it
> > introduces the risk that pages are deployed without the snippet,
> > placing the burden on the developers to know about these snippets that
> > have to be placed in every view they create!
>
> > However, some pages need to completely override the default version in
> > the layout.
> > For example, analytics doesn't auto track 40x/50x HTTP responses, so I
> > want to change the analytics code for specific views.
>
> > So right now, my layout renders the analytics element, passing it a
> > variable form viewVars if necessary.
>
> > Then, my error page for 404s etc sets this variable to a custom value
> > ("error-404") so we can track how often our users hit error pages.
>
> > This technique is DRY (no unnecessary repetition of the same snippet),
> > employs convention over config (the convention is analytics is handled
> > in the layout, unless you're dealing with a special case), and there's
> > no risk of analytics not being included on a page.
>
> > None of the suggestions so far seem as elegant as this...?
>
> [snip]
--~--~-~--~~~---~--~~
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: What am I missing ($conditions in a find)?

2009-04-09 Thread czg

Same thing happens if I replace "generatetreelist" with "findAll"
-BP

On Apr 9, 3:22 pm, cartosys  wrote:
> my conditions:
>
>                 $sqlConditions = array(
>                                 'Node.lft' => ">= ".$node["Node"]["lft"],
>                                 'Node.rght' => "<= ".$node["Node"]["rght"]);
>
>                 $nodes = $this->Node->generateTreeList($sqlConditions);
>
> and this is the resulting query (from debug level 2):
>
> SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
> `nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
> 15' ORDER BY `Node`.`lft` asc
>
> why aren't the comparison operators <= and >= not replacing the =
> operator?
>
> -BP
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



What am I missing ($conditions in a find)?

2009-04-09 Thread cartosys

my conditions:

$sqlConditions = array(
'Node.lft' => ">= ".$node["Node"]["lft"],
'Node.rght' => "<= ".$node["Node"]["rght"]);

$nodes = $this->Node->generateTreeList($sqlConditions);

and this is the resulting query (from debug level 2):

SELECT `Node`.`id`, `Node`.`title`, `Node`.`lft`, `Node`.`rght` FROM
`nodes` AS `Node` WHERE `Node`.`lft` = '>= 4' AND `Node`.`rght` = '<=
15' ORDER BY `Node`.`lft` asc


why aren't the comparison operators <= and >= not replacing the =
operator?

-BP


--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread smithtrev...@googlemail.com

Ok, now I've done that, I've spent the last couple of hours trying to
insert the parsed xml into a database table called teams.

However, I am struggling to do so.
I've had a few tries using  a number of different methods.
http://abeautifulsite.net/notebook/42
http://www.codewalkers.com/c/a/Database-Code/The-opposite-of-mysqlfetchassoc/
and a couple of others.
But no luck.

The parsed XML looks like this.
array(1) { ["Teams"]=>  array(1) { ["Team"]=>  array(20) { [0]=>  array
(2) { ["value"]=>  string(7) "Arsenal" ["id"]=>  string(1) "7" } [1]
=>  array(2) { ["value"]=>  string(11) "Aston Villa" ["id"]=>  string
(1) "9" } [2]=>  array(2) { ["value"]=>  string(16) "Blackburn
Rovers" ["id"]=>  string(2) "17" } [3]=>  array(2) { ["value"]=>
string(16) "Bolton Wanderers" ["id"]=>  string(2) "20" } [4]=>  array
(2) { ["value"]=>  string(7) "Chelsea" ["id"]=>  string(2) "31" } [5]
=>  array(2) { ["value"]=>  string(7) "Everton" ["id"]=>  string(2)
"53" } [6]=>  array(2) { ["value"]=>  string(6) "Fulham" ["id"]=>
string(2) "60" } [7]=>  array(2) { ["value"]=>  string(9) "Hull
City" ["id"]=>  string(2) "72" } [8]=>  array(2) { ["value"]=>  string
(9) "Liverpool" ["id"]=>  string(2) "82" } [9]=>  array(2) { ["value"]
=>  string(15) "Manchester City" ["id"]=>  string(2) "86" } [10]=>
array(2) { ["value"]=>  string(17) "Manchester United" ["id"]=>  string
(2) "87" } [11]=>  array(2) { ["value"]=>  string(13)
"Middlesbrough" ["id"]=>  string(2) "90" } [12]=>  array(2) { ["value"]
=>  string(16) "Newcastle United" ["id"]=>  string(2) "95" } [13]=>
array(2) { ["value"]=>  string(10) "Portsmouth" ["id"]=>  string(3)
"104" } [14]=>  array(2) { ["value"]=>  string(10) "Stoke City" ["id"]
=>  string(3) "377" } [15]=>  array(2) { ["value"]=>  string(10)
"Sunderland" ["id"]=>  string(3) "127" } [16]=>  array(2) { ["value"]
=>  string(17) "Tottenham Hotspur" ["id"]=>  string(3) "129" } [17]=>
array(2) { ["value"]=>  string(20) "West Bromwich Albion" ["id"]=>
string(3) "403" } [18]=>  array(2) { ["value"]=>  string(15) "West Ham
United" ["id"]=>  string(3) "137" } [19]=>  array(2) { ["value"]=>
string(14) "Wigan Athletic" ["id"]=>  string(3) "138" } } } }





Any help on how to do it would be great.

Thanks.
Sorry for spamming 3 posts...
--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread smithtrev...@googlemail.com

Ok, I've managed to do it by using the XML file directly from the
website, and not using a local copy. This is definitely much better.
Thanks for your 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: CAKE_ADMIN

2009-04-09 Thread Gwoo

You probably downloaded 1.2 but are reading about 1.1.
--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread smithtrev...@googlemail.com

Ok, I tried the test, and also print_r($parsed_xml) and var_dump
($parsed_xml).

When I tried the test, with all of them except var_dump($parsed_xml),
it again just showed "Array".
But with var_dump($parsed_xml) it shows:
array(1) { ["Testxml"]=>  array(2) { ["test2"]=>  string(17) "Content
of test 2" ["anothernode"]=>  string(22) "Content of anothernode" } }

When I used var_dump($parsed_xml) with the code from my last post, it
showed:
array(0) { }

I suspect this means it's not working?

The XML document I am using is the source of this page:
http://11v11.com/api/teams/season/2009/xml/y
Is this invalid?

Thanks.




On Apr 9, 4:23 pm, Mathias Hunskår Furevik 
wrote:
> Hi,
>
> $parsed_xml should be an array representation of the XML. If nothing
> is returned (you could also try print_r($parsed_xml) or
> var_dump($parsed_xml) ) then your XML is probably malformed or not
> loaded.
>
> Try making a simple test like this and show us the output:
>
> $tstxml = " Content of test 2
> Content of anothernode";
>
> And load the string with new XML($tstxml);
>
> If your source file is invalid you could use the SimpleHTMLDom class I
> suggested. It accepts invalid HTML/XML and is quite easy to work with.
>
> //mathias
>
> 2009/4/9 smithtrev...@googlemail.com :
>
>
>
> > Thanks for your help. I've been using this code and I think it's sort
> > of worked.
>
> > function index() {
> >     App::import('Xml');
> >    $file = "http://localhost\parses\y.xml";;
>
> >    $parsed_xml =& new XML($file);
> >    $parsed_xml = Set::reverse($parsed_xml); // this is what i call
> > magic
>
> >    debug($parsed_xml);                         //(I've also tried
> > $echo parsed_xml)
> >  }
>
> > Although when I go to view the index.ctp file in my browser, which I
> > think should display the whole array, a blank page appears with just
> > the word Array at the top.
> > Any reason for this? Or how I can view the whole array?  Is it even
> > actually parsing the XML?
> > Thanks in advance.
--~--~-~--~~~---~--~~
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: DB2 and integer ids!

2009-04-09 Thread Gwoo

You will have to look at the driver for DB2. If you need to override
it you can place it in app/models/datasources or submit a patch.
--~--~-~--~~~---~--~~
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: read () select data to return

2009-04-09 Thread Dave

OK unbind model. I managed to unbind 1 model but how unbind multiple
models at one?

$this->User->unbindModel(array('hasMany' => array('Message')));

thanks

Dave

On Apr 9, 2:29 pm, "Dave Maharaj :: WidePixels.com"
 wrote:
> Can anyone assist me with this?
>
> In the standard controller view function there is this:
>
> $this->set('user', $this->User->read(null, $id));
>
> which gets all the User info from the tables based on the ID but I do not
> want every thing returned. I have information for that User in their profile
> function which only they have access to. The view function is public for
> everyone to see and want to limit the information returned.
>
> Right now it returns Users / Educations / Messages / Preferences information
> from the tables but I would like to only return info from the Users and
> Educations tables.
>
> How can I choose what tables to return info from?
>
> Thanks,
>
> Dave
--~--~-~--~~~---~--~~
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: read () select data to return

2009-04-09 Thread Dave Maharaj :: WidePixels.com

I actually just used unbind to not get any results from the 2 models since
in that particular layout I do not need any data from those associated
tables.

Thanks for the info and time.

Dave



-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: April-09-09 2:33 PM
To: cake-php@googlegroups.com
Subject: Re: read () select data to return


You could either use find() along with 'contain' or you could simply not
display certain fields in the view.

On Thu, Apr 9, 2009 at 12:29 PM, Dave Maharaj :: WidePixels.com
 wrote:
>
> Can anyone assist me with this?
>
> In the standard controller view function there is this:
>
> $this->set('user', $this->User->read(null, $id));
>
>
> which gets all the User info from the tables based on the ID but I do 
> not want every thing returned. I have information for that User in 
> their profile function which only they have access to. The view 
> function is public for everyone to see and want to limit the information
returned.
>
> Right now it returns Users / Educations / Messages / Preferences 
> information from the tables but I would like to only return info from 
> the Users and Educations tables.
>
> How can I choose what tables to return info from?
>
> Thanks,
>
> Dave
>
>
> >
>



--~--~-~--~~~---~--~~
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: login voodoo

2009-04-09 Thread brian

2009/4/9 Jorge Horacio Cué Cantú :
> Hello,
>
>
> Set
>
> $this->Auth->redirect = false
>
> in AppController::beforeFilter().
>
> The   the login() action will be called after a successful login.
>

Thanks, that's it (sort of). The var is actually $this->Auth->autoRedirect.

So, for the record:

AppController:
function beforeFilter()
{
$this->Auth->fields = array('username' => 'email', 'password' => 
'password');
$this->Auth->loginError = 'No matching user found.';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 
'login');
$this->Auth->loginRedirect = array('controller' => 'pages', 'action'
=> 'display', 'home');
$this->Auth->autoRedirect = false;
$this->Auth->logoutRedirect = array('controller' => 'users', 'action'
=> 'login');

if (isset($this->params['admin']) && $this->params['admin'])
{
$this->layout = 'admin';
}
}


UsersController:
public function login()
{
if ($user = $this->Auth->user())
{
$this->User->id = $user['User']['id'];
$this->User->saveField('last_login', date('Y-m-d H:i:s'));

if (!$user['User']['eula_accepted'])
{
$this->redirect(
array('controller' => 'users', 'action' => 
'eula')
);
}
$this->redirect($this->Auth->loginRedirect);
}
}

public function eula()
{
if (!empty($this->data) && $this->data['User']['eula_accepted'])
{
$this->User->id = $this->Auth->user('id');
$this->User->saveField('eula_accepted', 1);
$this->Session->write('Auth.User.eula_accepted', 1);

$this->redirect(
array('controller' => 'pages', 'action' => 'display', 
'home')
);
}
}

Thanks again, Jorge!

--~--~-~--~~~---~--~~
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: read () select data to return

2009-04-09 Thread brian

You could either use find() along with 'contain' or you could simply
not display certain fields in the view.

On Thu, Apr 9, 2009 at 12:29 PM, Dave Maharaj :: WidePixels.com
 wrote:
>
> Can anyone assist me with this?
>
> In the standard controller view function there is this:
>
> $this->set('user', $this->User->read(null, $id));
>
>
> which gets all the User info from the tables based on the ID but I do not
> want every thing returned. I have information for that User in their profile
> function which only they have access to. The view function is public for
> everyone to see and want to limit the information returned.
>
> Right now it returns Users / Educations / Messages / Preferences information
> from the tables but I would like to only return info from the Users and
> Educations tables.
>
> How can I choose what tables to return info from?
>
> Thanks,
>
> Dave
>
>
> >
>

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



CAKE_ADMIN

2009-04-09 Thread centavo

Hi!

In the 1.1 Collection of the manual, section: 5 Configuration, I'm
reading through the  section "Advanced Routing Configuration: Admin
Routing and Webservices"

The third paragraph begins:

"To enable this, first, uncomment the CAKE_ADMIN line in your /app/
config/core.php file."

So, I go to app/config/core.php and look for CAKE_ADMIN, but it
doesn't exist.

What am I missing?

Thank you.

--~--~-~--~~~---~--~~
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: login voodoo

2009-04-09 Thread Jorge Horacio Cué Cantú
Hello,


Set

$this->Auth->redirect = false

in AppController::beforeFilter().

The   the login() action will be called after a successful login.

Regards.


2009/4/9 brian 

>
> Actually, yes, I did consider that and I think I will do it that way.
> But that still leaves with this problem: how to check this field after
> a successful login?
>
> On Thu, Apr 9, 2009 at 11:48 AM, Angry Coder  wrote:
> >
> > Have you considered a separate column in your users table of
> > "accepted_eula" or "eula_version_accepted" if you want to track which
> > version of the EULA they have accepted?
> >
> > It would be easy then to force users to re-accept if it changes and
> > you do not have to lose the "last_login" data if you wish to force a
> > re-acceptance.
> >
> > Just thinking out loud here...
> > >
> >
>
> >
>

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



read () select data to return

2009-04-09 Thread Dave Maharaj :: WidePixels.com

Can anyone assist me with this?
 
In the standard controller view function there is this:

$this->set('user', $this->User->read(null, $id)); 


which gets all the User info from the tables based on the ID but I do not
want every thing returned. I have information for that User in their profile
function which only they have access to. The view function is public for
everyone to see and want to limit the information returned.
 
Right now it returns Users / Educations / Messages / Preferences information
from the tables but I would like to only return info from the Users and
Educations tables.
 
How can I choose what tables to return info from?

Thanks,

Dave 


--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread Mathias Hunskår Furevik

Hi,

$parsed_xml should be an array representation of the XML. If nothing
is returned (you could also try print_r($parsed_xml) or
var_dump($parsed_xml) ) then your XML is probably malformed or not
loaded.

Try making a simple test like this and show us the output:

$tstxml = " Content of test 2
Content of anothernode";

And load the string with new XML($tstxml);

If your source file is invalid you could use the SimpleHTMLDom class I
suggested. It accepts invalid HTML/XML and is quite easy to work with.

//mathias



2009/4/9 smithtrev...@googlemail.com :
>
> Thanks for your help. I've been using this code and I think it's sort
> of worked.
>
> function index() {
>     App::import('Xml');
>    $file = "http://localhost\parses\y.xml";;
>
>    $parsed_xml =& new XML($file);
>    $parsed_xml = Set::reverse($parsed_xml); // this is what i call
> magic
>
>    debug($parsed_xml);                         //(I've also tried
> $echo parsed_xml)
>  }
>
> Although when I go to view the index.ctp file in my browser, which I
> think should display the whole array, a blank page appears with just
> the word Array at the top.
> Any reason for this? Or how I can view the whole array?  Is it even
> actually parsing the XML?
> Thanks in advance.
> >
>

--~--~-~--~~~---~--~~
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: XML parsing

2009-04-09 Thread smithtrev...@googlemail.com

Thanks for your help. I've been using this code and I think it's sort
of worked.

function index() {
 App::import('Xml');
$file = "http://localhost\parses\y.xml";;

$parsed_xml =& new XML($file);
$parsed_xml = Set::reverse($parsed_xml); // this is what i call
magic

debug($parsed_xml); //(I've also tried
$echo parsed_xml)
  }

Although when I go to view the index.ctp file in my browser, which I
think should display the whole array, a blank page appears with just
the word Array at the top.
Any reason for this? Or how I can view the whole array?  Is it even
actually parsing the XML?
Thanks in advance.
--~--~-~--~~~---~--~~
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: login voodoo

2009-04-09 Thread brian

Actually, yes, I did consider that and I think I will do it that way.
But that still leaves with this problem: how to check this field after
a successful login?

On Thu, Apr 9, 2009 at 11:48 AM, Angry Coder  wrote:
>
> Have you considered a separate column in your users table of
> "accepted_eula" or "eula_version_accepted" if you want to track which
> version of the EULA they have accepted?
>
> It would be easy then to force users to re-accept if it changes and
> you do not have to lose the "last_login" data if you wish to force a
> re-acceptance.
>
> Just thinking out loud here...
> >
>

--~--~-~--~~~---~--~~
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: login voodoo

2009-04-09 Thread Angry Coder

Have you considered a separate column in your users table of
"accepted_eula" or "eula_version_accepted" if you want to track which
version of the EULA they have accepted?

It would be easy then to force users to re-accept if it changes and
you do not have to lose the "last_login" data if you wish to force a
re-acceptance.

Just thinking out loud here...
--~--~-~--~~~---~--~~
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: Get "last deleted id" from afterDelete?

2009-04-09 Thread grigri

In the afterDelete() callback, $this->id (or $model->id) in a behavior
will refer to the just-deleted model. It's cleared after the callbacks
have been called, just before Model::del() returns.

hth
grigri

On Apr 9, 4:09 pm, park  wrote:
> Hi,
>
> Working on a set of models, in which after one model got its record
> updated, the Log model will be manipulated accordingly.
>
> $cascade = true of Model:del() doesn't seem to work, 'coz models
> mentioned above are not associated. (Log model has a field 'item_id'
> that is shared by all other models, recording their ids but
> diffrentiated by another field 'model'. )
>
> Is it possible to get the last deleted record id from whatever
> beforeDelete or afterDelete callbacks?
>
> If not, I guess I'll have to extend Model::del in order to get this,
> right? Is there a DRY approach of doing this? (Like writing a
> behavior)
>
> Many 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: login voodoo

2009-04-09 Thread brian
OK, it looks like one can't override login() with AuthComponent in
place. I was sure I could, and it doesn't make sense to me that I
can't. If someone knows otherwise, please advise.

So, I tried putting my code in isAuthorized().


AppController:
function beforeFilter()
{
$this->Auth->fields = array('username' => 'email', 'password' => 
'password');
$this->Auth->loginError = 'No matching user found.';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 
'login');
$this->Auth->loginRedirect = array('controller' => 'pages', 'action'
=> 'display', 'home');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action'
=> 'login');
$this->Auth->authorize = 'controller';

if (isset($this->params['admin']) && $this->params['admin'])
{
$this->layout = 'admin';
}
}

UsersController:

function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allowedActions = array('eula', 'register', 
'reset_password');
}

public function login() {}

function isAuthorized()
{
$user = $this->Auth->user();
Debugger::log($user);

if (empty($user['User']['last_login']))
{
Debugger::log('redirecting ...');
$this->Auth->redirect(
array(
'controller' => 'users',
'action' => 'eula'
)
);
}
else
{
/* save the login time
 */
$user['User']['last_login'] = date('Y-m-d H:i:s');
$this->User->save($user);

$this->Session->write('Auth.User', $user['User']);
}
return true;
}

Now, I can't log in at all! I tried putting return true; just inside
isAuthorized() and still Auth is emitting AuthError. That makes no
sense at all.

On Thu, Apr 9, 2009 at 10:49 AM, brian  wrote:
> I need to direct first-time users to an EULA page for a client's
> extranet. I thought I'd check the last_login field in order to decide
> whether to redirect there or not. However, for some reason, I'm being
> logged in but none of my custom code is running.
>
> function beforeFilter()
> {
>        parent::beforeFilter();
>        $this->Auth->allowedActions = array('eula', 'register', 
> 'reset_password');
> }
>
>
> public function login()
> {
>        if (!empty($this->data))
>        {
>                if ($this->Auth->login($this->data))
>                {
>                        $user = $this->Auth->user();
>
>                        if (empty($user['User']['last_login']))
>                        {
>                                $this->Auth->redirect(
>                                        array(
>                                                'controller' => 'users',
>                                                'action' => 'eula'
>                                        )
>                                );
>                        }
>                        else
>                        {
>                                /* save the login time
>                                 */
>                                $user['User']['last_login'] = date('Y-m-d 
> H:i:s');
>                                $this->User->save($user);
>
>                                $this->Session->write('Auth.User', 
> $user['User']);
>                        }
>                }
>                else
>                {
>                        $this->Session->setFlash($this->Auth->authError);
>                }
>        }
> }
>
>
> At first, I thought that the redirect() call was bad or something.
> But, if I toss in a die(debug('logged in')); right after the login()
> call, that doesn't run, either.
>
> So, how am I being logged in? I wondered if Cake's magic was getting
> in the way so I did this:
>
> public function login()
> {
>        if (!empty($this->data))
>        {
>                die(debug('got data'));
>
>                // ...
>
> This never fires, either. So, I then did this:
>
>
>
> public function login()
> {
>        die(debug('wtf'));
>
> Guess what? This fires.
>
> Anyone got a tip for me?
>

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



Reverse "LIKE" sql statement

2009-04-09 Thread sylvainhugues

Hi every one,

If I wanna fetch a db entry how got "blue car" in a field,
1 > I can set "WHERE fieldName LIKE '%blue%' "
2 > But how could I make the opposite ? I got "blue car" and I wanna
find an entry whith "blue". Obviously LIKE '%blue car%' will not work.

(I don't wanna (can't) handle "blue car" String, and have to use it
like that.)

Merci infiniment, Sylvain.

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



DB2 and integer ids!

2009-04-09 Thread nvrs

Hi all,

I am considering cake as a front-end to a large db2 database and i
have this weird problem, which does not apply to mssql and mysql
databases. Whenever i try to a view an entry from a table by clicking
on the respective link on the index page, i get an SQL Error: 42818.
The cause is that when cake attempts to retrieve the record it escapes
the id value of the entry in the query with single quotes (as if the
field was a string), e.g.

SELECT FROM tests AS Test WHERE Test.id = '1' FETCH FIRST 1 ROWS ONLY

This happens with both scaffolding enabled and disabled - it doesn't
matter if i explicitly declare the table schema!

I am using cake 1.2.1.8004, DB2 9.1 and the PECL ibm_db2 (1.6.5 which
is a bit old) binary driver that comes with the latest PECL binary
archive for windows.

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



complex HABTM question

2009-04-09 Thread luke83

Hi there,
first question, complex question :D

i have tables in db like this:

+ leagues
| - lid
| - name

+ users
| - uid
| - name

+ groups
| - gid
| - name

+ league_staff
| - lid
| - gid
| - uid

The models:

class League extends AppModel {
var $name = 'League';
var $primaryKey = 'lid';
var $hasAndBelongsToMany = array(
'Staff' =>
array(
'className'  => 'User',
'joinTable'  => 'league_staff',
'foreignKey' => 'lid',
'associationForeignKey'  => 'lid',
'with'   => 'LeagueStaff',
'unique' => true,
'conditions' => '',
'fields' => '',
'order'  => '',
'limit'  => '',
'offset' => '',
'finderQuery'=> '',
'deleteQuery'=> '',
'insertQuery'=> ''
)
);
}

class User extends AppModel {
var $name = 'User';
var $primaryKey = 'uid';
}

class Group extends AppModel {
var $name = 'Group';
var $primaryKey = 'gid';
}

class LeagueStaff extends AppModel {
var $name = 'LeagueStaff';
var $primaryKey = 'gid';
var $useTable = 'league_staff';
var $hasOne = array(
'Group' => array(
'className'  => 'Group',
'foreignKey' => 'gid',
)
);
}

This is what i got:

[leagues] => Array
(
[0] => Array
(
[League] => Array
(
[lid] => 1
[name] => first league
)

[Staff] => Array
(
[0] => Array
(
[uid] => 1
[name] => luke83
[LeagueStaff] => Array
(
[lid] => 1
[uid] => 1
[gid] => 1
)

)

)

)
)


This is what i would like:

[leagues] => Array
(
[0] => Array
(
[League] => Array
(
[lid] => 1
[name] => first league
)

[Staff] => Array
(
[0] => Array
(
[uid] => 1
[name] => luke83
[Group] => Array
(
[gid] => 1
[name] => admin
)

)

)

)
)

it is like when LeagueStaff is invoked the hasOne attribute is not
considered

Can someone explain me what i do wrong?

Thanks for time :D

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



Limiting select to certain values

2009-04-09 Thread Toby

Hi there,

I have 4 table that relate to this problem...
- Products
- Types
- Sizes
- StockItems

I have set CakePHP so that each product has a Type.
I am now sorting out the StockItems controller/views.  Each StockItem
will relate to a single Product and will specify the Size of the
StockItem.

My question is... On the StockItem Edit page, how do I limit the Size
drop-down to only display the Sizes that relate to the Type of the
Product?

I started off by trying to get this to work in the Add view, but of
course, the Product for the record was not sat at this point!  Doh!

Any help would be appreciated.  Here's what I have in my model at the
moment...

  var $belongsTo = array(
'Product' => array(
  'className' => 'Product',
  'foreignKey' => 'product_id',
  'conditions' => '',
  'fields' => '',
  'order' => ''
),
'Size' => array(
  'className' => 'Size',
  'foreignKey' => 'size_id',
  'conditions' => array('Size.size_type_id' =>
'StockItem.Product.size_type_id'),
// I have also tried with...
// 'conditions' => array('Size.size_type_id' =>
'Product.size_type_id'),
  'fields' => '',
  'order' => ''
)
  );

Thanks,

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



Get "last deleted id" from afterDelete?

2009-04-09 Thread park

Hi,

Working on a set of models, in which after one model got its record
updated, the Log model will be manipulated accordingly.

$cascade = true of Model:del() doesn't seem to work, 'coz models
mentioned above are not associated. (Log model has a field 'item_id'
that is shared by all other models, recording their ids but
diffrentiated by another field 'model'. )

Is it possible to get the last deleted record id from whatever
beforeDelete or afterDelete callbacks?

If not, I guess I'll have to extend Model::del in order to get this,
right? Is there a DRY approach of doing this? (Like writing a
behavior)

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

2009-04-09 Thread brian

I need to direct first-time users to an EULA page for a client's
extranet. I thought I'd check the last_login field in order to decide
whether to redirect there or not. However, for some reason, I'm being
logged in but none of my custom code is running.

function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allowedActions = array('eula', 'register', 
'reset_password');
}


public function login()
{
if (!empty($this->data))
{
if ($this->Auth->login($this->data))
{
$user = $this->Auth->user();

if (empty($user['User']['last_login']))
{
$this->Auth->redirect(
array(
'controller' => 'users',
'action' => 'eula'
)
);
}
else
{
/* save the login time
 */
$user['User']['last_login'] = date('Y-m-d 
H:i:s');
$this->User->save($user);

$this->Session->write('Auth.User', 
$user['User']);
}
}
else
{
$this->Session->setFlash($this->Auth->authError);
}
}
}


At first, I thought that the redirect() call was bad or something.
But, if I toss in a die(debug('logged in')); right after the login()
call, that doesn't run, either.

So, how am I being logged in? I wondered if Cake's magic was getting
in the way so I did this:

public function login()
{
if (!empty($this->data))
{
die(debug('got data'));

// ...

This never fires, either. So, I then did this:



public function login()
{
die(debug('wtf'));

Guess what? This fires.

Anyone got a tip for me?

--~--~-~--~~~---~--~~
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: Paginator with "table name"."field"

2009-04-09 Thread Celso

sortBy do not exists !!! :(

http://api.cakephp.org/class/paginator-helper



On 8 abr, 03:24, Elavazhagan chidambaram 
wrote:
> this is ur code sort('MUNICIPIO',
> 'Municipio.Nome_municipio'); ?>
>
> this code right code  $paginator->sortBy('Municipio.Nome_municipio', 'MUNICIPIO'); ?>
>
> On Tue, Apr 7, 2009 at 9:34 PM, Celso  wrote:
>
> > Hi! I have this problem:
>
> > sort('MUNICIPIO',
> > 'Municipio.Nome_municipio'); ?>
>
> > result in:
>
> >    a href=" ... /sort:Municipio.Nome_municipio/ ...
>
> > next("Proximo"); ?>
>
> > result in:
>
> >    a href="  ... /sort:Nome_municipio/ ...
>
> > Only works with same model...
> > Why?
>
> > Celso.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Data validation always return true

2009-04-09 Thread brian

set() is called from within save() before validation. If you need to
call validates() yourself, you must first set the data.

http://book.cakephp.org/view/410/Validating-Data-from-the-Controller
http://api.cakephp.org/view_source/model/#line-1094

On Thu, Apr 9, 2009 at 10:05 AM, Rhee  wrote:
>
> Maybe I am just too idiot to understand this.
> I know what $this->Model->set() do. But I used for adding a new data
> set in database. Also, it has no ID / primary key yet, by the time i
> called set() method. So what did set() do, so that validate() can be
> called properly after that?
>
> On Apr 9, 3:52 pm, brian  wrote:
>> On Thu, Apr 9, 2009 at 8:06 AM, Rhee  wrote:
>>
>> > Next question, why is it now working? What did $this->Model->set() do?
>> > Can you gimme short explanation?
>>
>> It sets the Primary Key for the model and $Model->data values.
>>
>> http://api.cakephp.org/class/model#method-Modelset
> >
>

--~--~-~--~~~---~--~~
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: Get $Auth->user() in Model?

2009-04-09 Thread park

I see.

Thanks a lot!

On Apr 8, 4:45 am, Miles J  wrote:
> You are not able to use Components in models. The best is to import
> the session component.
>
> App::import('Component', 'Session');
> $Session = new SessionComponent();
>
> $user = $Session->read('Auth.User');
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Data validation always return true

2009-04-09 Thread Rhee

Maybe I am just too idiot to understand this.
I know what $this->Model->set() do. But I used for adding a new data
set in database. Also, it has no ID / primary key yet, by the time i
called set() method. So what did set() do, so that validate() can be
called properly after that?

On Apr 9, 3:52 pm, brian  wrote:
> On Thu, Apr 9, 2009 at 8:06 AM, Rhee  wrote:
>
> > Next question, why is it now working? What did $this->Model->set() do?
> > Can you gimme short explanation?
>
> It sets the Primary Key for the model and $Model->data values.
>
> http://api.cakephp.org/class/model#method-Modelset
--~--~-~--~~~---~--~~
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: HABTM Count

2009-04-09 Thread rossjha

This seems to be working.

$this->Tag->unbindModel(array('hasAndBelongsToMany' => array
('Improvements')));
$this->Tag->bindModel(array('hasOne' => array(
'ImprovementsTag',
'FilterTag' => array(
'className' => 'Tag',
'foreignKey' => false,
'conditions' => array('FilterTag.id =
ImprovementsTag.tag_id')
)
)));
$tags = $this->Tag->find('all', array(
'conditions'=>null,
'fields' => array('Tag.*', 'COUNT(FilterTag.id) 
AS no_tags'),
'group' => 'Tag.id'
));

Array
(
[0] => Array
(
[Tag] => Array
(
[id] => 1
[title] => Effective Glucose Control
)

[0] => Array
(
[no_tags] => 2
)

)

Is there a way of tidying this array so no_tags is part of the Tag
element?

Cheers

R

On Apr 9, 1:45 pm, "ross.hagg...@googlemail.com"
 wrote:
> Hi i have the following associations:
>
> var $hasAndBelongsToMany = array('Improvements');
> var $hasAndBelongsToMany = array('Tags');
>
> With a join table improvements_tags
>
> I want to be able to count the number of time a tag has been used.
> The following sql query works, but i'm not sure how to do this in
> CakePHP?
>
> SELECT tags.id, tags.title, COUNT(improvements_tags.tag_id) AS no_tags
> FROM tags, improvements_tags WHERE tags.id = improvements_tags.tag_id
> GROUP BY tags.id
>
> I've tried to bindModel with a count in the find condition, but it
> never seems to work.  Any help would be really appreciated.
>
> Ross
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Data validation always return true

2009-04-09 Thread brian

On Thu, Apr 9, 2009 at 8:06 AM, Rhee  wrote:
>
> Next question, why is it now working? What did $this->Model->set() do?
> Can you gimme short explanation?
>

It sets the Primary Key for the model and $Model->data values.

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

--~--~-~--~~~---~--~~
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: The right way to pass vars from a view to the layout?

2009-04-09 Thread mark_story

$this->set() doesn't work?

http://api.cakephp.org/class/view#method-Viewset

-Mark

On Apr 8, 9:40 am, the_woodsman  wrote:
> To my mind, a controller shouldn't need to know about the ugly
> semantics of Javascript dependencies etc - it's entirely presentation
> related, is irrelevant to other output types (xml, csv), etc...
>
> And on a practical note, we have client-side guys in the team, who
> don't really edit controllers etc.
>
> I'm entirely happy with the general mechanism we're using at the
> moment, I just want to make it a bit more seamless, i.e not
> referencing viewVars in both the view and layout! Anyone advise on how
> I'd wrap this up in method calls, where they would live, etc?
>
> On Apr 8, 2:35 pm, jsundquist  wrote:
>
> > Why not pass something from the controller to the layout and use a
> > beforeRender?
>
> > On Apr 8, 8:12 am, the_woodsman  wrote:
>
> > > Exactly - the layout renders an analytics element, but it can pass it
> > > a variable that was set in the actual view.
>
> > > On Apr 8, 1:40 pm, John Andersen  wrote:
>
> > > > Thanks for trying :)
>
> > > > Do I understand correctly, that you are invoking/calling/whatever an
> > > > element (Google Analytics) from the layout?
> > > >    John
>
> > > > On Apr 8, 2:27 pm, the_woodsman  wrote:
>
> > > > > John, let me give it another go!
>
> > > > > Googl analytics is still my best example.
>
> > > > > I want every single page to have the basic analytics snippet.
> > > > > I really don't want to have this in every single view- it'd be a big
> > > > > job to go through all the existing views and add the call to render
> > > > > the element (not very DRY), it makes my views more cluttered, and it
> > > > > introduces the risk that pages are deployed without the snippet,
> > > > > placing the burden on the developers to know about these snippets that
> > > > > have to be placed in every view they create!
>
> > > > > However, some pages need to completely override the default version in
> > > > > the layout.
> > > > > For example, analytics doesn't auto track 40x/50x HTTP responses, so I
> > > > > want to change the analytics code for specific views.
>
> > > > > So right now, my layout renders the analytics element, passing it a
> > > > > variable form viewVars if necessary.
>
> > > > > Then, my error page for 404s etc sets this variable to a custom value
> > > > > ("error-404") so we can track how often our users hit error pages.
>
> > > > > This technique is DRY (no unnecessary repetition of the same snippet),
> > > > > employs convention over config (the convention is analytics is handled
> > > > > in the layout, unless you're dealing with a special case), and there's
> > > > > no risk of analytics not being included on a page.
>
> > > > > None of the suggestions so far seem as elegant as this...?
>
> > > > [snip]
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HABTM Count

2009-04-09 Thread ross.hagg...@googlemail.com

Hi i have the following associations:

var $hasAndBelongsToMany = array('Improvements');
var $hasAndBelongsToMany = array('Tags');

With a join table improvements_tags

I want to be able to count the number of time a tag has been used.
The following sql query works, but i'm not sure how to do this in
CakePHP?

SELECT tags.id, tags.title, COUNT(improvements_tags.tag_id) AS no_tags
FROM tags, improvements_tags WHERE tags.id = improvements_tags.tag_id
GROUP BY tags.id

I've tried to bindModel with a count in the find condition, but it
never seems to work.  Any help would be really appreciated.

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



Re: Data validation always return true

2009-04-09 Thread Rhee
@ logout: sure maybe there is an error there, I didn't only copy paste
the source, I did some modification to cover up the real messages ...
But thanks a lot for your concern. ;-)

On Apr 9, 2:02 pm, logout  wrote:
> Is this a typo here:
>
> 'alphanumeric' => array (
>                                 'rule'          => 'alphaNumeric',
>                                 'message'       => 'Error
> )
>
> because the Error is missing the closing '
>
> On Apr 8, 6:41 pm, brian  wrote:
>
> > > $this->User->validates($this->data); // always return true
> > > $this->User->save($this->data); // always return true, and try to save
>
> > You say it always returns true, but are you testing that in an if block?
>
> > On Wed, Apr 8, 2009 at 9:59 AM, Rhee  wrote:
>
> > > Hi,
>
> > > the data validation in my User Model always return true. Can anybody
> > > tell me why?
>
> > > In Model:
>
> > >        var $validate = array (
> > >                'login' => array (
> > >                        'notempty' => array (
> > >                                'rule'          => array('custom', 
> > > VALID_NOT_EMPTY),
> > >                                'message'       => 'Error'
> > >                        ),
> > >                        'unique' => array (
> > >                                'rule'          => 'isUnique',
> > >                                'message'       => 'Error'
> > >                        ),
> > >                        'minlength' => array (
> > >                                'rule'          => array ('minLength', 
> > > '5'),
> > >                                'message'       => 'Error'
> > >                        ),
> > >                        'alphanumeric' => array (
> > >                                'rule'          => 'alphaNumeric',
> > >                                'message'       => 'Error
> > >                        )
> > >                ),
> > >                'passwd' => array (
> > >                        'minlength' => array (
> > >                                'rule'          => array ('minLength', 
> > > '8'),
> > >                                'message'       => 'Error'
> > >                        )
> > >                ),
> > >                'title' => array (
> > >                        'rule'          => array ('inList', array ('Mr.', 
> > > 'Mrs.')),
> > >                        'message'       => 'Error'
> > >                ),
> > >                'forename' => array (
> > >                        'rule'          => array('custom', 
> > > VALID_NOT_EMPTY),
> > >                        'message'       => 'Error'
> > >                ),
> > >                'name' => array (
> > >                        'rule'          => array('custom', 
> > > VALID_NOT_EMPTY),
> > >                        'message'       => 'Error'
> > >                ),
> > >                'email' => array (
> > >                        'rule'          => array ('email', true),
> > >                        'message'       => 'Error'
> > >                )
> > >        );
>
> > > In Controller:
>
> > > $this->User->validates($this->data); // always return true
> > > $this->User->save($this->data); // always return true, and try to save
> > > the data, which is of course error, due to NOT NULL constrains in
> > > database.
>
> > > Thanks for the help.- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Data validation always return true

2009-04-09 Thread Rhee

Yes of course, i did test it in if-block ... ;-)

Code looks like this:

if ($this->User->validates($this->data))
{
  // This block will be always executed
}

Anyway, i found how to work around it. Before if-block, i put set().
Code:

$this->User->set($this->data);
if ($this->User->validates()) // Really like this, without $this-
>data as input params.
{

}

At least it works now as it should be.
Next question, why is it now working? What did $this->Model->set() do?
Can you gimme short explanation?

Thanks ...

On Apr 8, 5:41 pm, brian  wrote:
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
>
> You say it always returns true, but are you testing that in an if block?
>
> On Wed, Apr 8, 2009 at 9:59 AM, Rhee  wrote:
>
> > Hi,
>
> > the data validation in my User Model always return true. Can anybody
> > tell me why?
>
> > In Model:
>
> >        var $validate = array (
> >                'login' => array (
> >                        'notempty' => array (
> >                                'rule'          => array('custom', 
> > VALID_NOT_EMPTY),
> >                                'message'       => 'Error'
> >                        ),
> >                        'unique' => array (
> >                                'rule'          => 'isUnique',
> >                                'message'       => 'Error'
> >                        ),
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '5'),
> >                                'message'       => 'Error'
> >                        ),
> >                        'alphanumeric' => array (
> >                                'rule'          => 'alphaNumeric',
> >                                'message'       => 'Error
> >                        )
> >                ),
> >                'passwd' => array (
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '8'),
> >                                'message'       => 'Error'
> >                        )
> >                ),
> >                'title' => array (
> >                        'rule'          => array ('inList', array ('Mr.', 
> > 'Mrs.')),
> >                        'message'       => 'Error'
> >                ),
> >                'forename' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'name' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'email' => array (
> >                        'rule'          => array ('email', true),
> >                        'message'       => 'Error'
> >                )
> >        );
>
> > In Controller:
>
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
> > the data, which is of course error, due to NOT NULL constrains in
> > database.
>
> > Thanks for the 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: Data validation always return true

2009-04-09 Thread logout
Is this a typo here:

'alphanumeric' => array (
'rule'  => 'alphaNumeric',
'message'   => 'Error
)

because the Error is missing the closing '

On Apr 8, 6:41 pm, brian  wrote:
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
>
> You say it always returns true, but are you testing that in an if block?
>
>
>
> On Wed, Apr 8, 2009 at 9:59 AM, Rhee  wrote:
>
> > Hi,
>
> > the data validation in my User Model always return true. Can anybody
> > tell me why?
>
> > In Model:
>
> >        var $validate = array (
> >                'login' => array (
> >                        'notempty' => array (
> >                                'rule'          => array('custom', 
> > VALID_NOT_EMPTY),
> >                                'message'       => 'Error'
> >                        ),
> >                        'unique' => array (
> >                                'rule'          => 'isUnique',
> >                                'message'       => 'Error'
> >                        ),
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '5'),
> >                                'message'       => 'Error'
> >                        ),
> >                        'alphanumeric' => array (
> >                                'rule'          => 'alphaNumeric',
> >                                'message'       => 'Error
> >                        )
> >                ),
> >                'passwd' => array (
> >                        'minlength' => array (
> >                                'rule'          => array ('minLength', '8'),
> >                                'message'       => 'Error'
> >                        )
> >                ),
> >                'title' => array (
> >                        'rule'          => array ('inList', array ('Mr.', 
> > 'Mrs.')),
> >                        'message'       => 'Error'
> >                ),
> >                'forename' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'name' => array (
> >                        'rule'          => array('custom', VALID_NOT_EMPTY),
> >                        'message'       => 'Error'
> >                ),
> >                'email' => array (
> >                        'rule'          => array ('email', true),
> >                        'message'       => 'Error'
> >                )
> >        );
>
> > In Controller:
>
> > $this->User->validates($this->data); // always return true
> > $this->User->save($this->data); // always return true, and try to save
> > the data, which is of course error, due to NOT NULL constrains in
> > database.
>
> > Thanks for the help.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Sessions lost

2009-04-09 Thread logout

In the core.php there is this section:

* The preferred session handling method. Valid values:
 *
 * 'php'Uses settings defined in your php.ini.
 * 'cake'   Saves session files in CakePHP's /tmp directory.
 * 'database'   Uses CakePHP's database sessions.
 *
 * To define a custom session handler, save it at /app/config/
.php.
 * Set the value of 'Session.save' to  to utilize it in CakePHP.
 *
 * To use database sessions, execute the SQL file found at /app/config/
sql/sessions.sql.
 *
 */
Configure::write('Session.save', 'php');

 By default, the sessions are handled by the php, so try to set it for
cake:

Configure::write('Session.save', 'cake');

 and make sure the /tmp directory is writable.
Or if you want to stick with the default, look for problems in your
active php.ini file...

On Apr 8, 4:16 pm, "Dr. Loboto"  wrote:
> Set debug > 0 and check for errors.
> Check session files store path to be writable by cake.
>
> On Apr 5, 11:32 pm, "Deud'tens"  wrote:
>
>
>
> >  Hello, sorry for my english, I'm french.
>
> > I have a god damn problem with sessions of cakephp : they don't work !
> > When I flash to another controller/action, everything is lost. I went
> > into the core.php file and lowered everything possible and tried all
> > the session handlers :
>
> > Configure::write('Session.checkAgent', false);
> > Configure::write('Security.level', 'low');
>
> > etc.
>
> > But it doesnt work. I already read many discussions about this problem
> > but I couldnt solve it. This is a simple example of what I want to
> > do :
>
> > CODE
>
> > 
> > class UsersController extends AppController
> > {
> >  function login()
> >  {
> >    if (!empty($this->data))
> >    {
> >      $userId = $this->User->loginVerif($this->data);
> >      if ($userId != null)
> >      {
> >        $this->Session->write('Login.id', $userId);
> >        print_r($_SESSION);//Works fine
> >        $this->flash("Vous vous êtes authentifié avec succès.", "/
> > quizzes/jouer");
> >      }
> >    }
> >  }}
>
> > ?>
>
> > And the controller called by the previous action :
>
> > CODE
>
> > 
> > class QuizzesController extends AppController
> > {
> >  function jouer()
> >  {
> >    echo $this->Session->read('Login.id');//Totally empty !
> >    $quiz = $this->Quiz->details();
> >    $this->set('quiz', $quiz);
> >  }}
>
> > ?>
>
> > I know that there's already an authcomponent, but it doesnt work, for
> > the same reasons I guess.
>
> > Thanks for all in advance !- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: share elements, helpers etc across multiple apps

2009-04-09 Thread majna

Did you see output from debug(Configure::getInstance()); ?

$behaviorPaths= array(ROOT.'common'.DS.'models'.DS.'behaviors');

controllerPaths
componentPaths
helperPaths
pluginPaths

On Apr 8, 3:19 pm, Ernesto  wrote:
> And... to share a behavior?
>
> On 7 Apr, 18:11, majna  wrote:
>
> > Setup additional view paths in config/bootstrap.php
> > $viewPaths = array(ROOT.'common'.DS.'views'.DS);
>
> > debug(Configure::getInstance());
>
> > On Apr 7, 4:34 pm, Ernesto  wrote:
>
> > > Hello.
>
> > > Is there a way tosharethe same helper or element file across
> > > multiple apps?
--~--~-~--~~~---~--~~
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: Subdomains and Routes

2009-04-09 Thread Aurelius

thx!

That was much easier as I expected, Cake rocks!


On 9 Apr., 02:31, schneimi  wrote:
> Hi Aurelius,
>
> I use something like this in config/routes.php:
>
> $subdomain = substr(env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"),
> "."));
>
> if ($subdomain != 'domain') {
>   Router::connect('/', array('controller' => 'users', 'action' =>
> 'view', 'pass' => $subdomain));
>
> }
>
> Regards,
>
> Michael
>
> On 9 Apr., 01:17, Aurelius  wrote:
>
> > Hi!
>
> > I want to have a subdomainrouting from
> > http://(.*).domain.com mappt to 
> > htpp://www.domain.com/users/view/username:$1,
> > which should be mappt standardwise like a normal cake app.(or mybe
> > directly).
>
> > I Don't really understand much about modRewrite and even less about
> > cakes dispatcher :-/
> > Can someone help me and tell me what I should replace?
>
> > thx
> > Aurelius
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Lightbox

2009-04-09 Thread Manisha

Hello All,

I am using http://bakery.cakephp.org/articles/view/lightroom-helper
for lightbox effect.

This is working properly for showing images not for HTML

Is it only for Images?

Manisha
--~--~-~--~~~---~--~~
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: Question about Routes and honoring MVC

2009-04-09 Thread Martin

The pages on my website are hierarchicaly structured as a tree, and
one of the mandatory requests for the website is to represent the page
hierarchy in the URLs. The pages and their relationships are defined
in a database table. So, what I would like to do is query the database
(and cache the results - if I understood correctly, CakePHP makes such
caching possible) and generate custom routes according to the page
paths.

For an example, this is the hieararchy (I know it's deep, but just to
draw the picture) for a targeted page which has its own controller:
Page1 -> Page2 -> Page3 -> TargetedPage

Id like to have the address looking like this: 
www.example.com/page1/page2/page3/targeted-page,
so 'page1/page2/page3/targeted-page' would be the matching url for the
page controller. The default Cake's setup doesn't work very well for
me here.

I know writing a simple query breaks the MVC principles, so is using a
controller and an appropriate model the right way to do this?

On 9 tra, 03:35, Miles J  wrote:
> How would information from adatabasebe used to make customroutes?
> Why not just use Cakes default setup.

--~--~-~--~~~---~--~~
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: IN statement in Findall

2009-04-09 Thread Markus Jürgens
hi!

   $data = $this->Blog->findAll(array('
>
> Blog.id' => array(7, 8, 9),array('Blog.blogId','Blog.
>>
>> blogImage','Blog.blogTitle'));
>
>


2009/4/9 kaushik 

>
> How to use not 'IN' in condition in finall()?
>
>$data = $this->Blog->findAll(array('Blog.id' =>
> '5'),array
> ('Blog.blogId','Blog.blogImage','Blog.blogTitle'));
>
> I want to change it so that it finds out id IN (7,8,9). How to do
> that?
> >
>

--~--~-~--~~~---~--~~
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: Use another model function from an unrelated model

2009-04-09 Thread dr. Hannibal Lecter

grigri had a nice clean solution for this:

http://bin.cakephp.org/saved/38624

On Apr 9, 12:13 am, Joe Critchley  wrote:
> You should probably use the ClassRegistry class.
>
> You can instantiate an unrelated model by doing the following:
>
> $ModelName = ClassRegistry::init('ModelName');
>
> ... and then use the functions from that variable, e.g...
>
> $ModelName->delete($id);
>
> Hope this helps.
>
> On Apr 8, 10:55 pm, lemp  wrote:
>
> > I’m building a statistical application and I need to access a function
> > that return reference values from a model that is unrelated with the
> > model where I need this data.
>
> > What is the best way to achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: validation notEmpty

2009-04-09 Thread sologroupmc

'Required' is not a rule as noted in 
http://book.cakephp.org/view/127/One-Rule-Per-Field

Your code should be:

var $validate = array(
 'blogCategoryId' => array(
  'rule' => 'notEmpty',
  'required' => true,
  'message'=>'Please select Blog category.'
 )
);


On Mar 4, 5:23 am, kaushik  wrote:
> I am using following code for validating anotempty field.
> var $validate = array(
>        'blogCategoryId' => array(
>                 'required' => array('rule' => 'notEmpty',
> 'message'=>'Please select Blog category.'),
>         )
>         );
>
> It is working properly but giving the following warning:
>
> Warning (2): preg_match() 
> [function.preg-match]:Delimitermustnotbealphanumericorbackslash[CORE/cake/libs/model/model.php,
>  line 2193]
>
> Can anyone highlight what is problem in code?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---